CINCINNATI (AP) -- Rickie Weeks and Cody Ransom hit two-run homers off Homer Bailey, and the Milwaukee Brewers avoided a three-game sweep by beating the Cincinnati Reds 8-4 on Wednesday afternoon.

Zack Greinke (9-2) remained unbeaten against the Reds, allowing two runs in six innings. Greinke is 4-0 in six career starts against Cincinnati.

Bailey (5-6) has had nothing but trouble against Milwaukee, falling to 0-5 in 10 games with a 6.50 ERA. He left after failing to get an out in the fifth inning, trailing 5-2.

The defending NL Central champions came to town hoping to take at least two of three and get back in the race. Instead, they dropped two of the three and left town 7 1/2 games behind the first-place Reds.

Milwaukee has been in an offensive slump lately. The Brewers didn't even manage a hit until the eighth inning of a 4-3 loss on Tuesday night. But they had 11 hits on Wednesday, including two doubles, a triple and two homers.

They wasted a bases-loaded, none-out chance to break the game open in the seventh inning, failing to score. Milwaukee put it away with three in the ninth off Jose Arredondo, who walked Aramis Ramirez and Corey Hart with the bases loaded.

Weeks hit a two-run homer in the second off Bailey, who snapped his glove toward the ground in anger as soon as the ball left the bat. Center fielder Chris Heisey jumped for the ball at the wall, but couldn't quite reach it.

Weeks' first homer since May 26 left him 11 of 20 career off Bailey with a pair of homers. It also made it 65 consecutive games at Great American Ball Park with at least one homer, the longest such streak since an 80-game stretch at Coors Field in 2002-03.

Ransom hit a two-run homer in the fourth for a 5-1 lead. Since the Brewers claimed him off waivers from Arizona on May 23, he'd been batting only .152 with one other homer.

The Brewers loaded the bases with no outs in the seventh, but Norichika Aoki struck out and Ransom was caught in a rundown off a failed suicide squeeze attempt with Nyjer Morgan at bat. Morgan then popped out.

Greinke allowed five hits and a pair of runs in six innings, including Ryan Ludwick's solo homer. Greinke is 4-0 in his last six starts overall, allowing a total of only eight runs.

Ludwick had another solo shot in the ninth off Livan Hernandez, his second multihomer game of the season.

Reds Gold Glove second baseman Brandon Phillips got hit in the face by Ramirez's arm while tagging him out on a steal attempt in the third. Phillips left the game three innings later as a precaution.

NOTES: The Brewers completed a 2-4 trip and returned home for a day off, followed by seven games against Arizona and Miami. ... The Reds head into the All-Star break with an 11-game trip to San Francisco, Los Angeles and San Diego. ... OF Ryan Braun was out of the Brewers' lineup with a tender left elbow, hit by Bronson Arroyo's pitch in the first inning on Tuesday night. Braun finished that game, but the elbow was bothering him a day later. ... Stubbs and 3B Scott Rolen were out of the Reds' starting lineup, getting some rest. ... Reds rookie SS Zack Cozart singled in the eighth, snapping an 0-for-19 slump.