Hamels (17-6) allowed five hits and walked only one in his final start of the year for the Phillies (80-79), who need one win in the final three-game series at Washington starting Monday to finish at least .500 for the 10th straight season.
Carlos Ruiz added three hits for Philadelphia, and Jonathan Papelbon worked his way around a pair of singles in the ninth to get his 38th save in 42 tries.
Jose Reyes had a pair of hits and Carlos Lee drove in a run for Miami, which lost for the 21st time in its last 29 games.
Marlins starter Nathan Eovaldi (4-13) gave up three runs - all in the first - and struck out seven in six innings.
By the time Hamels took the mound, the Phillies had staked him to a 3-0 lead. And with the way Hamels was throwing - 6-0 as the Phillies won nine of his last 10 starts - that cushion looked enormous.
Hamels retired his first 10 batters and threw 31 of his first 39 pitches for strikes. Maybe his early success shouldn't have been that surprising, considering Hamels entered with a better batting average (.227) than four players in the Marlins' starting lineup (Gorkys Hernandez, .177; Bryan Petersen, .193; John Buck, .197; and Eovaldi, .100).
About the only throws he struggled with were ones to first and second.
Hamels tried to make a pickoff throw to second base in the fourth, sending it past shortstop Jimmy Rollins and allowing Reyes to jog to third. Reyes scored on Lee's single as the Miami closed to 3-1. But the margin got no smaller, as Petersen and Giancarlo Stanton were thrown out at home in the inning.
Another errant throw by Hamels put Reyes on the move again in the sixth, but the Phillies escaped unscathed.
Hamels fielded Reyes' bunt and threw past first base - replays suggested Reyes would have beaten it anyway. Reyes went to second on the error, then stole third, but Hamels stranded him after getting Stanton to pop up in the infield and striking out Lee.
Hamels finished the year with a career-best 216 strikeouts in 215 1-3 innings. According to STATS LLC, the only players entering Sunday with at least 215 innings and 215 strikeouts this season were Detroit's Justin Verlander, the New York Mets' R.A. Dickey, Seattle's Felix Hernandez and the Los Angeles Dodgers' Clayton Kershaw.
Chase Utley hit a sacrifice fly in the first for Philadelphia, followed by a run-scoring double by Ruiz and an RBI single from Nate Schierholtz. Juan Pierre helped set up the inning with a sneaky slide into second on a play where the throw from the outfield clearly beat him to the base, but he found a way to avoid the tag.
Later in the first, the Phillies had Ruiz caught off second when Reyes caught a line drive hit by Domonic Brown. But Reyes' flip to second baseman Donovan Solano was errant, Ruiz got back safely, and scored one batter later on Schierholtz's single.
NOTES: Philadelphia won the season series, 10-8. ... Phillies RHP Tyson Brummett had his contract selected and will join the team in Washington on Monday. Philadelphia transferred C Brian Schneider was transferred to the 60-day DL. ... Philadelphia sends RHP Kyle Kendrick to the mound in Washington on Monday to face Nationals' LHP John Lannan. Miami stays home to face the Mets, with RHP Josh Johnson going for the Marlins against New York RHP Jeurys Familia.