Gallardo gave up only three hits, struck out four and walked two in pitching six shutout innings. He started in place of injured ace Ben Sheets.
Matt Wise pitched the last three innings for his first save.
Tony Graffanino highlighted the Brewers' hitting attack with a home run.
Livan Hernandez was the losing pitcher.
The Diamondbacks have lost eight of their last nine road games.