The Pittsburgh Pirates scored early, kept putting up runs against Yovani Gallardo and finished him in the fifth inning.

By then, though, the Milwaukee Brewers had done even more damage.

The wild-card contending Pirates lost for the 10th time in 13 games after being outslugged by Milwaukee 12-8 Sunday.

Ryan Braun hit his NL-leading 37th home run and Gallardo also connected. Jeff Bianchi, Rickie Weeks and Carlos Gomez also went long as the Brewers tied a season high with five homers.

Garrett Jones, Michael McKenry and Gaby Sanchez homered for the Pirates, who got swept in the three-game series.

"Every game right now is key," Sanchez said. "We've got to go out there and keep playing baseball, keep trying to have fun out there and continue pushing forward. All we can do is go out there and battle and give everything we've got."

Pirates starter James McDonald (12-7) was tagged for eight runs and six hits in 2 2-3 innings. He struck out six, but allowed four home runs.

"I actually felt good. The fastball command wasn't bad. They hit good pitches," McDonald said. "I'm not going to make any excuses for what happened. Bottom line is they put the bat on the ball and hit away."

Pirates pitchers need to do more to subdue the Brewers hitters, manager Clint Hurdle said.

"One thing we've got to do, that I haven't seen done since I've been here, is we've got to eliminate some of their comfort at the plate," Hurdle said. "They've been pushing us around for years."

Pirates hitters found success of their own against Gallardo. They touched him for 11 hits and seven earned runs in 4 2-3 innings. He also walked four while throwing a season-high 119 pitches.

"He wasn't sharp, his command was off," Hurdle said. "That's the funny part of the game. You tell me we're going to have seven off Gallardo in the fifth and chase him, let's roll. But that doesn't work that way."

Gallardo entered the game with a major league-leading 22 quality starts. He had won each of his previous six starts, posting a 1.90 ERA during the stretch.

"He was out of whack. He's thrown so well for so long. He just had a game where he wasn't on," Brewers manager Ron Roenicke said.

Milwaukee has won six in a row at home and 14 of its last 16 at Miller Park.

Kameron Loe (5-4) picked up the victory and John Axford got his 23rd save. Axford came in with two runners on base and recorded three consecutive outs.

Braun hit a three-run homer in the first, a 458-foot drive. After McKenry hit a leadoff homer in the second, the Brewers scored three more in the bottom half.

Bianchi had his second homer and Weeks launched a 455-foot shot off the center-field scoreboard. Weeks finished with three hits and scored four times.

McKenry hit a two-run single in the third that pulled Pittsburgh to 6-4. Gomez hit a two-run homer in the bottom half and chased McDonald.

Gallardo homered in the fourth. It was his 10th career home run, extending his franchise record for a pitcher.

Jones hit his 23rd homer in the sixth.

NOTES: The Pirates have hit 16 home runs in nine games at Miller Park this season, the most by any visiting team. ... Brock Holt of the Pirates got his first major league start, playing second base and leading off. He recorded his first career hit when he singled in the fourth inning. He also singled in the fifth, driving in his first run. ... Jeff Locke is scheduled to start for the Pirates on Monday against Houston. He was recalled from Triple-A Indianapolis, where he was 10-5 with a 2.48 ERA in 24 starts. Locke made two relief appearances earlier this season for the Pirates.