Alonso hit his 27th home run in the fourth, breaking the Mets record for most by a rookie in an entire season set by Darryl Strawberry in 1983.
With the Mets clinging to a one-run lead, Baez launched his 19th homer of the season with Kyle Schwarber and Anthony Rizzo on base and one out. Baez sent an 0-2 pitch from Seth Lugo (3-1) halfway up the right field bleachers.
"He just kind of hanged it out a bit and I got the barrel on it," Baez said. "I think when I get to two strikes, I try to see the ball better and cut down my swing, which is pretty hard for me because I gotta swing hard."
Baez learned that it was his 100th homer after returning to the dugout and being mobbed my teammates.
"It's really exciting," Baez said. "I thought it was going to be a little bit later on in my career."
Mets starter Jacob deGrom allowed two runs and eight hits in six innings. The NL Cy Young Award winner struck out nine and walked none.
DeGrom also drove in a run with a single.
Alonso's solo shot to center came on a soft 0-2 pitch from Hamels in the fourth that Hamels said resulted from a "mixup" with catcher Victor Caratini. The 24-year-old had homered on Saturday to set a new mark for NL rookies before the All-Star break.
"Thankfully I saw two of them in the previous at-bat and saw it long enough and put a really good swing on it," Alonso said. "I'm proud of it, but I wish we won today. It was a tough loss."
Alonso connected in his 77th game while Strawberry hit 26 in 133 games in 1983. The Mets' record for homers in a season is 41, shared by Carlos Beltran and Todd Hundley.
Baez said he talked to Alonso during the series and tipped his cap to the rookie.
"He doing something amazing," Baez said. "He's almost got 30 homers and we've still got two more weeks until the All-Star break. I like the way he's playing the game and the way he's hitting the ball."
Strawberry also took note.
"Congrats to Pete for breaking my record which has stood for a long time," Strawberry said in a statement. "What he's done in a short period of time is most impressive. No goal seems out of reach."
Alonso is nearing Mark McGwire's major league record for homers by a rookie before the All-Star break, 33 set in 1987.
Tomas Nido also homered for the Mets.
Hamels helped his cause with an RBI single and Rizzo drove in Chicago's other run as the Cubs salvaged a split in the four-game series.
Hamels yielded three runs on seven hits through seven innings.
NEW YORK STATE OF MIND
Mets manager Mickey Callaway cursed at Newsday reporter Tim Healey, and pitcher Jason Vargas had to be restrained from charging him during a confrontation in the team's clubhouse after the game.
Reporters asked repeatedly after the game about Callaway's decision to stick with Lugo instead of going to closer Edwin Diaz. After the press conference, Callaway walked past Healey in the clubhouse. Healey told Callaway he would "see you tomorrow," and Callaway responded by calling Healey an obscenity. Callaway walked away and then returned, cursing at Healey again and telling him to leave the clubhouse.
Vargas then stared down Healey and eventually tried to charge him. Players stepped in to restrain the veteran left-hander.
No punches were thrown, and Healey left the clubhouse moments later.
RHP Craig Kimbrel is expected to pitch at least one more time for Triple-A Iowa, probably Tuesday, before the Cubs consider recalling the closer, manager Joe Maddon said.
After tossing a scoreless inning Friday, Kimbrel threw again Saturday as an opener for Iowa in a rain-shortened contest. The right-hander allowed a run and got two outs as he pitched in back-to-back games for the first time since finalizing a three-year, $43 million deal with the Cubs on June 7.
Mets: Callaway said before the game he had no timeline on next steps for RHP Noah Syndergaard (right hamstring), who threw a bullpen on Saturday. "We'll talk to the player and see exactly what we want to do next," Callaway said. Syndergaard is eligible to come of the 10-day IL on Wednesday.
Cubs: Chicago activated RHP Tony Barnette (right shoulder inflammation) off the 60-day injured list and optioned RHP Rowan Wick to Triple-A Iowa. Barnette, 35, started the season on the IL. He went 2-0 with a 2.39 ERA in 22 relief appearances for Texas in 2018 before a shoulder strain ended his season in early July.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
MLB DFS picks for Thursday's DraftKings and FanDuel Daily Fantasy contests including Freddie Freeman
Rating every player available for DraftKings or FanDuel contests from Poor to Great using the industry-leading daily projection tool The Bat, by DFS expert Derek Carty.
Jurickson, Juremi and now Judrick: There's another Profar ready to rock Williamsport
As the youngest brother becomes the third Profar to play in the Little League World Series, we caught up with his MLB sibling to discuss the family legacy and baseball in Curacao.
Reds licking wounds ahead of meeting Cardinals
The Cincinnati Reds were making their presence known with 10 wins in a 14-game stretch before punctuating a four-game skid with a lopsided loss in their latest outing.
Pujols climbing hits list as Angels face White Sox
Albert Pujols is fresh off a historic performance that provided the slumping Los Angeles Angels with a much-needed injection of elation.
A's take aim at Astros in AL West showdown
The Athletics' longshot bid to catch the Houston Astros in the American League West begins Thursday night when the clubs open a four-game series in Oakland.
Rangers aim for playoff push against Twins
The Texas Rangers find themselves 10 games out of an American League wild-card spot with just 42 games remaining as they open a four-game series with the Minnesota Twins on Thursday night in Arlington, Texas.