Gallardo (9-9), who missed just over two weeks with a strained hamstring, baffled the Reds, who managed just three hits and two walks off him. Gallardo struck out three.
Brandon Kintzler hurled 1 2/3 scoreless innings and Jim Henderson struck out the side in the ninth for his 18th save as the Brewers took a second straight from their division rivals.
Milwaukee scored both its runs on a Logan Schafer double in the fourth inning.
Mat Latos (12-4) was hung with his first loss since July 11, a stretch of six starts, yielding two runs on six hits and three walks in a seven-inning effort. He fanned six.
The Reds' lead over Arizona for the second National League wild card spot shrank to four games.