It was the fourth homer of the season for Stewart, hitless in his previous four games. Reed Johnson added a pinch-hit home run in the sixth for Chicago.
The Cubs won despite a relatively short outing from starter Jeff Samardzija, who threw 91 pitches in five innings despite giving up only one run on three hits and two walks. The converted reliever had won two straight coming into Sunday.
Struggling Cubs reliever Kerry Wood pitched a scoreless eighth, stranding Ryan Braun on third, and Michael Bowden finished the ninth. Shawn Camp (1-1) earned the win.
Brewers starter Marco Estrada went six innings, giving up five hits and two runs, both on solo homers. Estrada didn't allow a baserunner in the first three innings.
Milwaukee took a 1-0 lead in the fourth, when Braun reached on a walk, went to second on a single by Aramis Ramirez, took third on a sacrifice bunt by Corey Hart and scored on a sacrifice fly by Taylor Green. Ramirez went to third on a wild pitch, but Samardzija struck out Brooks Conrad to end the inning.
Stewart's homer tied the game in the fifth, and the Cubs took the lead on Johnson's homer in the sixth.
Hart made a diving catch of a deep line drive by Starlin Castro later in the sixth, preventing an extra-base hit and possibly saving Milwaukee a run with speedy Tony Campana on first.
Ramirez walked with two outs in the sixth and Hart doubled to put runners on second and third. Green then hit a grounder to shortstop and slid into first to beat the throw for an infield hit while Ramirez scored to tie the game.
But the Cubs regained the lead in the seventh when Stewart doubled, then scored when shortstop Edwin Maysonset threw high to first on a grounder by Darwin Barney. Stewart took third, then was awarded home plate on the error for a 3-2 lead.
A pair of Cubs errors - one by Stewart at third and the other by first baseman Bryan LaHair, who failed to catch a pickoff throw - put Cesar Izturis on third base with one out. But Barney threw out Izturis at the plate on a grounder to second by Norichika Aoki, and Jonathan Lucroy flied out to end the inning.
The Cubs added a pair of runs in the eighth when Campana walked, went to second on a fielder's choice and stole third. Brewers reliever Manny Parra walked LaHair, then unleashed a wild pitch that allowed Campana to score.
Alfonso Soriano doubled to score LaHair, and Soriano took third on another wild pitch, but Stewart grounded out to end the inning.
The Cubs added three runs in the ninth on an RBI double by Barney and RBI singles by Campana and Castro.
Kameron Loe (2-1) took the loss.
NOTES: Brewers outfielder Carlos Gomez, on the 15-day disabled list with a strained left hamstring, will go on a minor league rehab assignment this week. ... Aoki hit his first career triple in the third. ... Johnson's shot was the Cubs' third pinch-hit home run this season.