MILWAUKEE -- Khris Davis didn't see where his game-winning hit went, but he figured something good had happened based on the reaction of his teammates.
Davis came through with a broken-bat two-run single with no outs in the bottom of the ninth off Pittsburgh closer Mark Melancon, giving the Brewers a 4-3 victory at Miller Park on Thursday.
"I didn't know where the ball was when I hit it. I was just looking around and all of a sudden my teammates were running at me," Davis said. ""I was looking to put the ball in play. I was actually calling timeout on the pitch and the umpire didn't give it to me. I just saw a good pitch and threw my hands at it."
The Pirates led 3-2 heading into the ninth behind a two-run homer by Tony Sanchez and a solo shot by Gaby Sanchez, both off starter Yovani Gallardo, who allowed three runs on five hits in 6 1/3 innings.
The Brewers had scored their only runs on solo homers by Rickie Weeks and Martin Maldonado off Wandy Rodriguez, who allowed four hits in five innings after being activated earlier in the day off the 15-day disabled list.
After the Pirates took the lead, it didn't appear as if the Brewers would muster much of a rally, striking out nine times over the next four innings.
"You're thinking something good needs to happen, somebody needs to get a big hit," Brewers manager Ron Roenicke said. "So, when you're scuffling offensively and they're just mowing you down, you're thinking somewhere along the line, one of our guys is going to get a big hit and we started off that way in the ninth."
Ryan Braun singled to right to start the ninth-inning rally. Melancon, who had recorded a save in each of his last four appearances, struggled to find the strike zone, walking Jonathan Lucroy on four pitches and then losing Mark Reynolds on a full count to load the bases. Davis then lined his game-winning single to center.
"He's got some big hits for us," said Roenicke. "When you look at his overall numbers and they're not where he would like them to be, or us, but he's got some big hits."
It was the fourth time this season the Pirates have lost when leading after eight innings.
"There wasn't any concern," Melancon said. "I just put myself in a bad spot. I know I could kick back and start throwing strikes … I was just in a tough spot."
The Pirates took a 2-1 lead in the fifth inning on Tony Sanchez's first home run, following a leadoff single by Jose Tabata.
"I need to stop making mistakes with guys on, especially with two strikes," said Gallardo, who has not won in seven starts since April 6. "You try to overthrow that slider and it just stays up in the zone and he hits it out."
Maldonado brought the Brewers even in the bottom of the inning, leading off with his second home run. Gaby Sanchez continued the exchange of long balls, sending the first pitch of the sixth over the wall in center for his fourth home run to put Pittsburgh back in front 3-2.
Weeks put the Brewers up 1-0 in the third, driving a 2-1 pitch for an opposite-field home run down the right-field line, his first homer since July 20 of last season.
The Brewers squandered an opportunity in the first when Weeks opened the inning with a double to right center and advanced to third on Jean Segura's bunt single. Braun then bounced into a 1-6-3 double play, with Weeks holding at third. Rodriguez escaped by retiring Lucroy on a ground out.
Weeks, who played sparingly in the opening weeks after losing the second-base job to Scooter Gennett, also adding an eighth-inning single as he extended his hitting streak to eight games. Since April 25, Weeks is hitting .593 (16-for-27).
"I obviously feel good," said Weeks, who has raised his average to .365 in 52 at-bats, compared with 122 for Gennett. " In the past, when I had hot streaks, I think I was more of a power, straight ahead, I'm-going-to-hit-the-ball-to-left-field type of hitter. Now, I'm spraying the ball to all parts of the field. Just trying to be more of a hitter."
The victory gave the Brewers their ninth series win of the season heading into a 10-game road trip to Chicago, Atlanta and Miami. They now are 8-2 vs. Pittsburgh this season.
"It feels pretty good," said Davis. "To win a series at home is always important and that's going to go a long ways to getting us in the playoffs."
Jim Hoehn is a contributor to MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.