Gallardo (10-5) allowed just four hits and walked one over seven innings. He also struck out six. LaTroy Hawkins pitched a 1-2-3 eighth and John Axford struck out three Diamondbacks in the ninth in collecting his 22nd save.
The Brewers had just three hits off Arizona starter Josh Collmenter before he was pulled after six innings. He may have been injured while running out a grounder in the top of the sixth.
Diamondbacks reliever Joe Paterson (0-2) lasted just three batters, two of whom singled. He was replaced by Sam Demel and McGehee was sent into pinch hit. He hit a 3-2 pitch over the wall in right center.
Kelly Johnson opened the game with a lead-off home run for Arizona but Gallardo then struck out the side and retired 16 of the next 17 batters he faced.