Khris Davis needed to do something productive at home.

The Milwaukee Brewers needed to avoid another frustrating offensive performance.

So, who needed a big hit in the ninth inning more, Davis or the Brewers?

"Both of us did," said manager Ron Roenicke.

Batting .132 at home this season with a mere three runs batted in, Davis delivered one of the biggest hits of the season Thursday afternoon with a two-run single in the bottom of the ninth inning that beat Pittsburgh, 4-3, at Miller Park.

The victory allowed the Brewers to go 5-4 on the home stand despite playing short-handed due to injuries and a suspension to Carlos Gomez. And if you don't think that's a big difference from going 4-5 and limping off to the longest road trip of the season, all you had to do was see the smiling faces in the home clubhouse.

"Winning a series at home is always important, and that's going to go a long ways to getting us in the playoffs," said Davis, who delivered the second walk-off hit of the home stand.

Other than home runs by white-hot Rickie Weeks (.593 since April 25) and Martin Maldonado, the Brewers had done very little against Pittsburgh lefty Wandy Rodriguez and the strong Pirates bullpen entering the ninth inning. Down, 3-2, they were left to wonder if a base-running mistake by Weeks in the first inning — he failed to come home from third as Pittsburgh turned a double play — might be the difference in the game.

Pittsburgh closer Jason Grilli was on the disabled list, but his replacement, Mark Melancon, is known as one of the best late-inning relievers in the league. But, much like the previous evening with Brewers closer Francisco Rodriguez, Melancon didn't have it on this day.

After Ryan Braun led off with a single, Melancon put himself in position to fail by walking Jonathan Lucroy and Mark Reynolds, who at first showed bunt. That brought to the plate Davis, who had delivered many clutch hits on the road (.306, seven RBI in 17 games) but struggled badly at home until this series.

Roenicke said he didn't consider sending veteran Lyle Overbay to bat for Davis for two reasons: Left-handed hitters hadn't fared well (.194) against the right-handed Melancon, and Davis had come through in the late innings.

"KD has got some big hits late for us," said Roenicke, whose first-place club ran its record to 8-2 against Pittsburgh this season.

"You look at his overall numbers (.227 batting average, .257 on-base percentage, four homers, 12 RBI) and they're not where he would like them to be or us, but he's got some big hits."