The Cubs won their second straight and protected their lead in the National League Central.
Chicago rallied from an early 2-0 deficit to make a winner out of Carlos Zambrano (11-4), who allowed two runs on six hits over seven innings.
Ronny Cedeno cut the Cubs' deficit in half in the third with a home run and Chicago then took control in the fifth against Scott Olsen (6-5).
Mark DeRosa walked to open the inning and Henry Blanco singled. After Cedeno struck out, Zambrano helped his own cause with an RBI double and Alfonso Soriano drew an intentional walk to load the bases. Derrek Lee worked a walk to force in the second run of the inning and Ramirez followed with a double to right.
Blanco tacked on a run with a homer in the sixth.
Carlos Marmol loaded the bases with two away in the ninth, but got Wes Helms to strike out on the 10th pitch of the at-bat to end the game. It was Marmol's fourth save.