Andrew McCutchen also homered for Pittsburgh, which had lost nine of 12 going into the series against the NL Central-leading Brewers. With the win, Pittsburgh now trails Milwaukee by five games.
Jeff Locke (5-3) pitched six strong innings, giving up two runs and two hits. He walked six, but was able to strand five runners.
Yovani Gallardo (8-7) lasted just five innings, allowing six runs on eight hits and three walks.
Ryan Braun's two-run homer in the first inning gave Milwaukee a 2-0 lead. It was his 16th home run of the season, but just his second since July 22 as he's been slowed by a sore thumb.
Pittsburgh came right back in the second for 3-2 lead, taking advantage of Gallardo's wildness as he issued two straight walk after an error by third baseman Aramis Ramirez. Jody Mercer hit a sacrifice fly and Harrison lined a two-run double.
The Pirates made it 4-2 on Neil Walker's RBI triple in the third and Harrison singled home a run in the fourth.
McCutchen hit his 18th home run of the season leading off the fifth. It was his third game since coming off the disabled list because of a rib fracture and it was his first home run since he hit two against Cincinnati on July 12.