Starlin Castro missed hitting for the cycle by a home run and collected a career-high four hits. New second baseman Blake DeWitt delivered a key two-out RBI single in the sixth and added a three-run homer in the eighth.
"It's good to win a ballgame," manager Lou Piniella said. "It's been awhile."
The win snapped a seven-game losing streak, and Chicago avoided being swept by Milwaukee for the first time since May 2002. The offense had been scuffling as the Cubs were outscored 67-20 and outhit 99-49 during the seven losses.
"It's been a rough go for a week," said Ryan Dempster (9-8). "We got our cake handed to us in Colorado, and the first couple games of the series have been rough. It was great to see the guys swing the bats the way they did."
Dempster notched his fifth straight win over the Brewers. The right-hander gave up three runs -- none earned because of a throwing error by third baseman Jeff Baker -- and struck out five over six innings. He was lifted in the sixth for a pinch-hitter, Ramirez. It was a good move.
The Cubs trailed 3-1 in the sixth when Castro was safe on an infield single. He moved up on a wild pitch by Manny Parra (3-9), and one out later, Marlon Byrd walked and Soto hit a RBI single to close to 3-2. One out later, DeWitt hit an opposite-field RBI single off an 0-2 pitch to tie the game, and Baker followed with another RBI single to go ahead.
Todd Coffey replaced Parra, and Ramirez greeted him by launching a 1-1 pitch into the bleachers in left-center for his 16th home run. Ramirez, who did not start to get a day off, was 2-for-21 in his last seven games and his last homer was July 20.
Ramirez was 1-for-17 against Coffey before the home run.
"He was due," Coffey said. "I guarantee you, the next 18 times, he'll be out."
Ramirez is only hoping he's in the starting lineup next time.
"I don't like [pinch-hitting]," Ramirez said. "It's hard; it's a hard job to do. Any time you do that, you're going to face a tough pitcher in a key situation."
The Cubs had two on and one out in the seventh when Soto connected off LaTroy Hawkins, who then hit Alfonso Soriano with a pitch and was ejected by home-plate umpire Tom Hallion. Milwaukee manager Ken Macha also was tossed after an extended argument.
Cubs pitchers hit Brewers batters four times in the series, and that was the first time a Chicago player was plunked.
"I'm not going to get into that," Piniella said.
The Cubs added five runs in the eighth, including three on DeWitt's first homer with the Cubs.
In the fourth, Colvin gave Chicago a 1-0 lead when he homered, dropping the ball into the corner bleacher seats in right. He now leads all Major League rookies in home runs, two ahead of the Mets' Ike Davis.
Colvin is tied for third on the Cubs' list of left-handed-hitting rookies. Hall of Famer Billy Williams leads the pack, hitting 25 home runs in 1961 when he won the National League Rookie of the Year. Walt Moryn is second with 23, set in 1956.
The National League Central-leading Reds now come to town.
"Let's hope this game gives us some impetus for the Cincinnati series," Piniella said. "They're playing good ball, and we want to compete well against them."
The Cubs will be playing the leaders of each division in the next two weeks.
"We're going to be playing teams that are certainly competing for postseason," Piniella said. "If that's the definition of a spoiler, let it be."