Javier Baez scored on a wild pitch in the bottom of the ninth to cap a wild 7-6 win over the Cincinnati Reds, in which the Cubs almost squandered a grand slam by Anthony Rizzo in the first inning and another strong start by John Lackey because of three home runs allowed by the bullpen.
Baez opened the bottom of the ninth with a double off Wandy Peralta (3-3) and pinch-hitter Jon Jay walked. Then, Ben Zobrist moved the runners with a groundout, but only after manager Joe Maddon was ejected during the at-bat.
Reliever Blake Wood came in and struck out Albert Almora Jr. But on the first pitch to Kris Bryant with two outs, Wood threw a breaking pitch that got away from catcher Tucker Barnhart, ending the game.
The Cubs are 1 1/2 games ahead of Milwaukee and 2 1/2 ahead of the St. Louis Cardinals.
Cincinnati's Joey Votto had his streak of reaching base at least twice in a game come to an end. Votto did reach once but he fell one game shy of tying Ted Williams' record of 21 straight games.
Wade Davis (3-1) pitched a perfect ninth, redeeming the bullpen, which surrendered a five-run lead.
The third grand slam of Rizzo's career came after both teams loaded the bases with their first three batters of the game.
The Reds managed just one run in the top of the first, while Rizzo regained the lead for Lackey with an opposite field blast, his 28th of the season.
Cincinnati put on seven baserunners in the first two innings against Lackey, but got just the one run in his six innings.
Lackey allowed one baserunner over his final four innings, retiring the final 10 without allowing a ball out of the infield. He had six strikeouts and walked three. Lackey is 5-0 with a 3.06 ERA since the All-Star break after going 5-9 with a 5.20 ERA in the first half. He was trying for a career-best sixth straight win.
Bailey allowed six earned runs in 5 2/3 innings, waking five and striking out 10.
Phillip Ervin became the first Reds player since Juan Francisco in 2009 to homer on his first career hit when his solo shot off reliever Hector Rondon made it 6-2 in the seventh inning.
Two batters later, Zack Cozart's home run off Rondon made it 6-4, forcing Maddon to insert Brian Duensing in the game. He got Votto to ground out, ending the rally and Votto's chance at history.
The teams will close the four-game series Thursday afternoon at Wrigley Field with LHP Jon Lester (8-7, 3.99 ERA) pitching for the home team against RHP Scott Feldman (7-7, 4.43).