Baez grounded a tying single with two outs in the ninth inning, Kris Bryant hit a two-run homer in the 10th and the Cubs widened their NL Central lead over Milwaukee, rallying past the Brewers 5-3 Thursday night.
Chicago is now 4 1/2 games ahead of the Brewers after winning the opener of a four-game series. The Cubs have won eight of nine.
The Cubs trailed 3-2 when Ian Happ led off the ninth by hitting a grounder that first baseman Neil Walker fielded wide of the bag. Reliever Jeremy Jeffress covered first and Happ was called safe in a close play, a ruling upheld on replay.
Happ moved to second on a one-out grounder and scored when Baez, down to his last strike, singled up the middle.
"There were so many plays tonight that could have been the turning point," Cubs starter Jake Arrieta said. "But down to our last strike, Javy comes up with a huge base hit up the middle to score the tying run. Just an incredible baseball game."
Cubs manager Joe Maddon wholeheartedly agreed.
"It was a pretty special game," he said. "Javy has been there before."
Brewers manager Craig Counsell didn't blame Jeffress.
"He did exactly what he was supposed to do," Counsell said. "He made great pitches. He threw a ball on his last pitch. It looked like it was just off the ground, and he just rolled the ball up the middle. Nothing wrong with the pitch. We just didn't have a fielder there."
Milwaukee was in position to win it in the bottom of the ninth, loading the bases with one out. But Wade Davis (4-1) struck out Domingo Santana and then, after falling behind 3-1 in the count to Orlando Arcia, came back to retire him on an easy comebacker on a full-count pitch.
Davis struck out the side in the 10th.
Jon Jay opened the Cubs 10th with a double and Bryant followed with his 28th homer, connecting off Oliver Drake (3-5).
"It was supposed to be down and away," Drake said. "I just left it up middle. That's what he does with those mistake pitches."
Anthony Rizzo followed Bryant with a drive off the top of the wall in center and wound up with a triple when a crew chief review showed the ball didn't leave the park.
"It could have gone one way or the other, but we made one more play than they did," Arrieta said. "That is what it boiled down to tonight."
Jeffress took over the ninth because closer Corey Knebel had pitched three days in a day. On Wednesday night, the Brewers lost at Pittsburgh 6-4 on Adam Frazier's walk-off homer against Knebel with two outs in the ninth.
Arrieta gave up one run and five hits over five innings in his first game since Sept. 4. The 2015 NY Cy Young winner had been sidelined by a strained right hamstring.
Kyle Schwarber hit his 29th homer for the Cubs, tagging 17-game winner Zach Davies, who gave up two runs in seven innings.
Cubs: Maddon says he isn't worried about LHP Jon Lester, who won his previous three starts before losing 8-1 to the Tampa Bay Rays on Wednesday night. "I believe in Jon Lester," Maddon said. "If he's hurting, and from my knowledge he's not, I think he's going to be fine."
"Every loss is going to be incredibly tough right now," Counsell said. "A 'W' is all that matters."
MONTGOMERY TO PEN
Maddon moved left-hander Mike Montgomery back to the bullpen with the return of Arrieta. Montgomery (7-8) went 2-2 in three starts and one relief appearance in September.
Cubs: RHP John Lackey (11-11, 4.62 ERA) looks to rebound from his shortest start of the season (4 2/3 innings) and ejection for arguing balls and strikes Sept. 15 against the St. Louis Cardinals. He is 6-4 with a 3.39 ERA in 14 career starts against the Brewers.
Brewers: RHP Brandon Woodruff (2-2, 2.38) aims for his fourth quality outing in his seventh career start and first against the Cubs.
More AP baseball: https://apnews.com/tag/MLBbaseball
Copyright 2017 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.