Alvarez hit a three-run shot in the fourth inning and a solo drive in the fifth against starter Wily Peralta (15-8). Russell Martin also connected for a three-run homer off the right-hander, who held the Pirates hitless for 3 2-3 innings but quickly fell apart and exited after five.
Pittsburgh starter Edinson Volquez (11-7) pitched out of trouble almost every inning to improve to 3-0 in five August starts. The right-hander allowed 11 hits and two walks in 5 2-3 innings, but Milwaukee only managed two runs off him.
Third-place Pittsburgh won its third consecutive game to pull within four of the NL Central-leading Brewers.
Each team had 12 hits, but Pittsburgh took advantage of its chances while Milwaukee squandered its opportunities.
Alvarez, making only his eighth start this month and his second career start at first base, went 2 for 3 with four RBIs, a walk and his seventh stolen base.
Martin was 2 for 4 with four RBIs, a double and a walk. Neil Walker went 3 for 4 with a double, a walk and three RBIs.
Peralta issued only one walk through 3 2-3 innings before giving Walker a free pass in the fourth. Martin then doubled and Alvarez hit his first homer since July 11 to give the Pirates a 3-2 lead.
The Brewers loaded the bases with one out in the bottom half, but Ryan Braun popped up and Aramis Ramirez struck out to end the threat.
Pittsburgh broke it open in the fifth. Walker hit an RBI double and Martin smacked his seventh homer, a three-run shot that landed in the Milwaukee bullpen. Alvarez followed with his second homer of the game and 17th of the season to make it 8-2.
Scooter Gennett homered in the second, his ninth, to give the Brewers a 1-0 lead.
Pirates: INF Clint Barmes has gone 3 for 15 in four rehab games with Triple-A Indianapolis. He's been on the disabled list since July 6 with a left groin injury. ... RHP Stolmy Pimentel (mild right ankle sprain) pitched a scoreless inning Thursday night to begin his rehab assignment with Double-A Altoona.
Brewers: RHP Matt Garza will throw a bullpen session Sunday. He's been on the DL with a left oblique strain since Aug. 5, retroactive to Aug. 4.
Pirates RHP Vance Worley (5-3) looks to bounce back from his worst start of the season when the teams conclude a three-game series Sunday. Worley allowed a season-high six runs in six innings Monday during a 7-3 loss to Atlanta.
Mike Fiers (3-1) will make his fourth start since replacing Garza in the rotation. Fiers has won all three of his previous starts and has a 0.86 ERA in those games.