LOS ANGELES -- Hanley Ramirez hit a walk-off three-run homer with two outs in the 12th inning, giving the Los Angeles Dodgers a 5-2 victory over the Chicago Cubs before 53,354 at Dodger Stadium on Saturday night.

Ramirez homered off reliever Blake Parker (1-1) as the Dodgers captured their seventh win in eight games and beat the Cubs for the 10th time in the last 12 meetings.

Dodgers center fielder Matt Kemp hit his 12th home run of the season in the win.

Chicago's Arismendy Alcantara had lined a run-scoring double into the gap in right center field to score Junior Lake to forge a 2-2 tie with two outs in the seventh inning. It stayed that way until Ramirez's winning blast.

A's 8, Royals 3

OAKLAND, Calif. -- Jon Lester made his Oakland debut and came away with the victory as the A's smashed through their recent scoring drought to beat Kansas City.

The left-hander came out of the game in the seventh inning to a standing ovation and tipped his cap to the fans. He gave up one run in the third inning and two in the seventh.

The A's, who had lost their previous two games, avoided what would have been just their second three-game skid this season. Oakland's 67-42 record is the best in baseball.

Cardinals 9, Brewers 7

ST. LOUIS -- Justin Masterson's St. Louis debut resulted in a win, despite some shaky moments on the mound at sold-out Busch Stadium.

The trade deadline acquisition from Cleveland made it through six innings and got plenty of run support while allowing seven hits and five runs, walking three and striking out four. He also poked a two-out single in the second that led to a five-run inning, and he laid down a perfect sacrifice bunt that set up a run in the fourth.

Closer Trevor Rosenthal pitched around a leadoff double by Jean Segura in the ninth for his National League-leading 33rd save as the Cardinals (58-51) drew within two games of the NL Central leading Brewers (61-50).

Pirates 8, Diamondbacks 3

PHOENIX -- Josh Harrison had three hits, including a home run, and Andrew McCutchen singled in the go-head run in a four-run eighth inning for Pittsburgh at Chase Field.

The Pirates won for the fifth time in seven games and moved with 1 1/2 games of NL Central leader Milwaukee.

David Peralta had three hits, including a two-run homer in the ninth inning, and Aaron Hill had two hits for Arizona (48-63), which has lost three of its last five.

Yankees 6, Red Sox 4

BOSTON -- Mark Teixeira homered and Derek Jeter delivered a two-run double to power New York past Boston at Fenway Park.

Rookie Shane Greene pitched into the fifth inning and Carlos Beltran went 2-for-5 with a double and RBI as the Yankees won for just the second time in their past seven games.

Greene gave up three runs and six hits in 4 2/3 innings, walking two, striking out five and departing with a 5-3 lead. Shawn Kelley (2-3) pitched 1 1/3 perfect innings for the win.

Stephen Drew -- traded from Boston to New York on Thursday -- put the Yankees up by three with an RBI double in the seventh inning.

Tigers 11, Rockies 5

DETROIT -- Rick Porcello gave up five hits in eight innings to win his 13th game as Detroit defeated Colorado at Comerica Park.

Miguel Cabrera, Victor Martinez and J.D. Martinez provided home run support for the Tigers.

Porcello (13-5) had 10 strikeouts, walked two and retired 11 batters in a row at one point while sending the Rockies to their sixth loss in seven games.