Gerut's second career grand slam capped a two-out rally that started when Randy Wells (10-9) walked No. 8 hitter Alcides Escobar, gave up a single to Brewers starter Dave Bush and another walk to Felipe Lopez.
Gerut, who played 11 games for the Cubs in 2005, drove a Wells pitch into the right-field bleachers for his seventh homer this season and just his third since Milwaukee acquired him from San Diego on May 21. He had only 11 RBIs for the Brewers in 70 games before Thursday.
Bush (5-7) allowed four runs and eight hits in 5 2-3 innings. Trevor Hoffman worked the ninth for his 33rd save in 36 chances.
Wells pitched only four innings, giving up five hits, five runs and five walks. Micah Hoffpauir pinch hit for Wells in the fourth and his two-run, two-out double cut Milwaukee's lead to 5-4.
But the Brewers loaded the bases for a third time in the seventh and Rivera hit a a two-out, two-run double off Esmailin Caridad.
NOTES: Bradley left with left knee inflammation after singling in the sixth inning ... The Cubs and Brewers honored 60 Medal of Honor recipients in a pregame ceremony, with the veterans lining up along the baselines where they were greeted by the players and souvenirs were exchanged. ... Milwaukee 1B Prince Fielder drew his 99th walk in the third to tie the season franchise record held by Jeromy Burnitz (2000). The 268-pound Fielder also legged out his third triple of the year in the fifth. ... Gerut's other grand slam came in 2003 against the Twins during his strong rookie season for Cleveland, when he hit 22 homers.