Rockies All-Star third-baseman Nolan Arenado left in the fifth inning with a left forearm contusion after Hamels (6-2) hit him with a pitch in the third, and three more batters - including Hamels - were hit by pitches later in the game.
Chicago's Kris Bryant was hit by pitches three times in the first two games of the series.
Arenado looked toward the mound after he was hit by Hamels' pitch, and he said something to the Chicago dugout before walking to first base. He was later forced out at second and played the field in the fourth, throwing out Addison Russell to start the inning. Ryan McMahon replaced him in the top of the fifth.
Rockies reliever Brian Shaw hit Hamels in the right foot with a pitch in the seventh inning, and Colorado rookie Phillip Diehl hit Anthony Rizzo in the eighth, drawing a warning to both dugouts from home plate umpire Roberto Ortiz.
Baez followed with a two-run homer, his 17th.
Cubs reliever Brad Brach hit Tony Wolters in the ninth but was not ejected.
Chicago scored five times in the second off Antonio Sentenzela (5-5). Jason Heyward had a two-run single and Schwarber hit three-run homer to the second deck in right-center, his 14th. Sentenzela lasted to the fifth inning, when he gave up three more runs, two on a single by Hamels.
Hamels got out of a bases-loaded jam in the first and breezed from there, allowing six hits and striking out nine. David Dahl had three of Colorado's hits.
Cubs: 3B Bryant was held out of the lineup. ''He's been ball-peened the last couple of days and on top of that he turned his ankle a couple of days ago,'' manager Joe Maddon said. ''We've got three lefties coming up in LA so I thought this might be a good day for him.''
Cubs: LHP Jon Lester (5-4, 3.56 ERA) will face Dodgers ace Clayton Kershaw in the opener of a four-game series at Los Angeles on Thursday night.
Rockies: RHP Jon Gray (5-5, 4.27) will open a four-game home series against San Diego on Thursday night.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports