Ryan Braun hit his NL-leading 37th home run, pitcher
Yovani Gallardo also connected and the Brewers won 12-8 Sunday, sending the Pirates to their 10th loss in 13 games.
The Brewers tied a season high with five home runs. The outburst pulled Milwaukee within 6 games in the postseason race.
"There's a second wild card. You never know what can happen," Braun said. "You just continue to compete every day. Obviously we'd have to play great baseball for the rest of the year but by no means are we giving up. We realistically think that we are still in it."
Brewers manager Ron Roenicke said he's been paying much more attention to the wild-card standings following his team's recent run of success, including three wins over Pittsburgh.
"I know we are looking ... a lot more than we were a couple of weeks ago," he said. "We're playing really good ball. It gets you excited about getting on a roll and seeing what happens."
Jeff Bianchi, Rickie Weeks and Carlos Gomez also connected for Milwaukee. The Brewers have won six in a row at home and 14 of their last 16 at Miller Park.
"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," Pirates manager Clint Hurdle said. "They've been pushing us around for years."
Garrett Jones, Michael McKenry and Gaby Sanchez homered for the Pirates.
"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 was tagged for 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."
Kameron Loe (5-4) picked up the victory in relief of Gallardo, who failed to complete the fifth inning.
John Axford closed out the game to earn his 23rd save. He came in with two runners on base and recorded three consecutive outs.
"We have hope," Loe said. "We'll take it."
The Pirates touched Gallardo for 11 hits and seven earned runs in 4 2-3 innings. He also walked while throwing a season-high 119 pitches.
"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. "The rhythm wasn't there. We tried to fight through it. We tried to get him through five. Unfortunately, we couldn't do it."
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.
Gallardo said he was struggling with his command even before he took the mound.
"Even in the bullpen, I was battling to find my rhythm and consistency with my release point," he said. "It was a crazy game today but we were able to get the win. That's the important thing."
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: Norichika Aoki returned to leadoff spot in the Milwaukee lineup and played right field after not starting the previous two games because of a stiff neck. ... 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.