MILWAUKEE (AP) -- Cody Ransom hit his first career grand slam with two outs in the eighth inning to lift the Milwaukee Brewers to a 10-7 victory over the Pittsburgh Pirates on Friday night.

Ryan Braun hit two home runs as Milwaukee improved to 40-6 against Pittsburgh at Miller Park since 2007. Martin Maldonado finished with a career-high four hits, all singles, to hand Pittsburgh only its third loss in the last 13 games.

Pittsburgh reliever Tony Watson (4-1) entered in the eighth and gave up consecutive singles to Braun and Aramis Ramirez. He struck out Corey Hart, but each runner stole a base on the pitch. The Pirates elected to load the bases by intentionally walking Rickie Weeks to face Ransom, who was 0 for 4 in the game.

Ransom hit a 2-2 pitch over the wall in left-center for his eighth homer of the season and the team's fourth grand slam of the year.

Pittsburgh's Andrew McCutchen hit a solo homer off John Axford in the ninth.

The Pirates had runners on first and second after reliever Manny Parra walked Neil Walker and gave up a single to McCutchen in the seventh. But he got out of the jam by retiring the next three batters.

Francisco Rodriguez (2-4) pitched the eighth.

In the sixth, Braun's second homer tied the score 6-6. Reliever Brad Lincoln hit the first batter he faced, Nyjer Morgan, but he was caught stealing with Braun at the plate. The NL all-star then smacked his league-leading 26th home run to right.

The game was anything but the expected pitcher's duel between Milwaukee's Zack Greinke and Pittsburgh's James McDonald. Both starters entered with 9-3 records but failed to make it to the sixth inning.

Greinke became the first pitcher since Red Faber of the Chicago White Sox in 1917 to start three consecutive team games in a season. But he gave up a solo home run to Pedro Alvarez in the fifth that gave Pittsburgh a 6-4 lead and was lifted in the bottom of the inning for a pinch-hitter. Greinke, 15-0 as a Brewer at Miller Park, allowed five earned runs and seven hits.

McDonald was 7-1 in his previous 10 starts but gave up four earned runs and eight hits in 4 2-3 innings, his third-shortest outing of the season. After a single by Martin Maldonado put runners at first and second with two outs in the fifth, he was replaced by Lincoln. Travis Ishikawa, hitting for Greinke, delivered a single to left to trim the Pirates' lead to 6-5.

Notes: Braun has 16 multi-homer games in his career, including four this year. . McDonald has not lost since June 15, at Cleveland. . Milwaukee's Aoki Norichika's 15-game hitting streak came to an end after he went 0 for 3 with two walks. . Greinke started Sunday and lasted only three innings, one day after he was ejected by first-base umpire Sam Holbrook after throwing only four pitches. He has not pitched more than six innings in his last five games and he allowed five or more earned runs for the fifth time.