The Cardinals moved to a season-high 14 games above .500 and extended their lead to four games in the NL Central over the Brewers, who lost their ninth straight.
St. Louis used the bullpen early after Michael Wacha was limited to three innings in his first start off the disabled list. Gonzales (2-2) went 2 1-3 innings for the win.
The Brewers stranded potential tying runs in scoring position from the sixth through the ninth.
St. Louis never trailed after Yadier Molina's two-run single in the first off Wily Peralta (15-10).
Still, the Brewers had numerous chances to snap out of their two-week funk.
Seth Maness got the Cardinals out of the sixth by inducing Logan Schafer to fly out in foul territory with a runner on third. Carlos Martinez got third-place hitter Jonathan Lucroy to pop out to end the seventh with another runner on third.
In the eighth, the Brewers put runners on first and second with nobody out against Pat Neshek. The side-arming right-hander bounced back by getting Martin Maldonado to pop up a bunt attempt before Schafer hit a hard-hit fly to the center-field wall for the second out.
Jean Segura sent a flare to left fielder Matt Holliday, ending the threat.
The Cardinals used six relievers in all, with closer Trevor Rosenthal issuing two walks to put runners on first and second with two outs in the ninth. Rosenthal got pinch-hitter Jason Rogers to fly out to the edge of the warning track in right for his 42nd save.
Cardinals: Wacha threw 50 pitches and struck out three. He allowed three hits, including Lucroy's RBI single in the first. The right-hander had been on the disabled list since June 18 with a right shoulder injury.
Brewers: Carlos Gomez pinch ran but remained out of the starting lineup with a left wrist injury. Manager Ron Roenicke said his leadoff hitter was feeling good, and the team doctor would re-evaluated Gomez in the hope that he might be able to return soon. Gomez has been sidelined since Monday.
Cardinals: John Lackey (2-1) gets the start Friday, when he hopes for a repeat performance of his first start with the Cardinals after being traded from Boston. He gave up two runs in seven innings in a 3-2 victory.
Brewers: Mike Fiers (4-2) is 1-0 with a 0.75 ERA in two career starts against the Cardinals, both coming in 2012.