Gallardo (16-8) struck out six and walked four to win his eighth straight decision as Milwaukee moved in front of fading Pittsburgh in the jumbled National League wild-card race. The teams entered the day 2 1-2 games back of the Cardinals, who played Houston later.
Ryan Braun had two hits, drove in a run and stole three bases for the Brewers, who have won six of seven. Milwaukee's seven stolen bases were the most by the franchise since it moved to the National League in 1998. Carlos Gomez and Jonathan Lucroy had three hits apiece for the Brewers.
A.J. Burnett (15-8) gave up two runs in six innings but couldn't stop Pittsburgh's late season swoon. The Pirates are 4-12 this month.
While the Pirates have stumbled, the Brewers have surged. Milwaukee trailed Pittsburgh by nine games during its last visit to PNC Park in late August, though Pittsburgh appeared to at least get some stability on Monday night during a 3-0 win in Chicago.
The Pirates waited out rain delay of more than three hours before taking care of the Cubs and didn't get home until 5:40 a.m.
Manager Clint Hurdle let his players arrive later than usual to the ballpark after the long night. The extra rest didn't help.
Gallardo has thrived as the team's No. 1 starter since Zack Greinke was traded to the Los Angeles Angels. The right-hander had little trouble extending his hot streak against the Pirates, who appeared only eager to get back home and crawl in bed.
The Brewers escaped a bases-loaded two-out jam in the second when Gallardo got Burnett to ground out to second.
Pittsburgh didn't get another base runner until the seventh, and by then Milwaukee had raced to a 4-0 lead.