The Brewers were up 4-2 going into the eighth and turned to reliever John Axford (0-3) but the Pirates had four of the six batters Axford faced reach base, including Marte on the home run.
Marte reached for a low pitch and drove it well over the wall in left-center field for a homer that tied the score 4-4. It was one of five home runs in the game.
Bryan Morris (1-1) came in in the seventh and threw two pitches, getting a double play and the win. Jason Grilli allowed a ninth-inning hit but still finished off his major-league leading 11th save.
Ryan Braun singled in a run in the first for the Brewers but a home run by Alvarez tied the score the next inning. Carlos Gomez and Yuniesky Betancourt hit back-to-back home runs in the Brewers' fourth for a 3-1 lead.
Pittsburgh's Michael McKenry hit a home run in the seventh, which was countered by Jean Segura's RBI single in the bottom of the inning.