The veteran southpaw served up eight strikeouts and allowed just three hits in seven shutout innings to pick up his third win of the season.
"It's kind of maintaining that desire to throw strikes and not give away free passes," said Hamels, who did not allow a walk in the victory.
Both squads went down in order in the first inning. The Cubs (8-9) brought in the first run as part of a two-out rally in the top of the second frame. Javier Baez began the inning with a strikeout before Jason Heyward grounded out.
Cubs catcher Willson Contreras then doubled off of Marlins starter Sandy Alcantara for the first hit of the inning. Second baseman Daniel Descalso followed with a single to left field, bringing in Contreras for a 1-0 lead.
The Marlins' misery continued when the Cubs put up a four spot in the third frame. Baez lined an RBI single to right field for Chicago's second run. Heyward then brought in Baez on another RBI single, before Descalso doubled in Contreras and Heyward for a 5-0 lead.
Baez returned for some more damage in the eighth frame, hitting a solo shot off Marlins pitcher Nick Anderson. Baez's bomb traveled 392 feet and had an exit velocity of 102 mph, according to Statcast.
The Marlins (4-15) have now been swept three times in their first six series to begin the 2019 season. Miami suffered 12 sweeps in 2018.
"[Hamels] is having a good time out there," Cubs manager Joe Maddon said. "I love that part about him. He has joy playing the game of baseball. Plus he swings the bat pretty well. Beyond that, it's just attack, attack, attack and if something goes awry he doesn't change his patterns."
Chicago entered the series with a 5-9 record, but has a chance to get back to .500 with an upcoming home series against the Arizona Diamondbacks.
"It's good. We obviously know we need to come in and start winning. We know we're a good ball club," Hamels said. "No matter what team we're playing, let's go out there and win. If we keep that mentality, that's how you start win streaks."
The Marlins host the Washington Nationals in a National League East series starting at 7:10 p.m. Friday at Marlins Park in Miami. Chicago hosts Arizona at 12:10 p.m. Wednesday at Wrigley Field.
"We are losing as a team," Marlins manager Don Mattingly said. "We aren't going to get separated by offense or defense or pitching or hitting. We are losing and we are losing in all different ways."