Hamels, coming off a five-hitter against Atlanta last Tuesday, scattered seven hits and struck out five in his sixth career shutout and 12th complete game. He walked one and threw 85 of 113 pitches for strikes.
It was the first time Hamels tossed two shutouts in a row. The previous Phillies pitcher to accomplish the feat was Cliff Lee, who had three straight in June 2011.
Hamels (13-6) entered 0-3 with a 5.21 ERA in three outings against the Marlins this season. But in his three August starts, he is 2-1 with a 0.72 ERA. He has struck out 20 and walked two.
Juan Pierre had three hits and Jimmy Rollins scored twice for the Phillies, who snapped a five-game losing streak against Miami.
Nathan Eovaldi (3-8) allowed three runs - two earned - and eight hits in five innings for the Marlins, who have lost four of five.
Chase Utley's RBI double and an error by third baseman Greg Dobbs gave the Phillies a 2-0 lead in the third inning. They extended it to 3-0 on a triple by Pierre down the right-field line that scored Rollins.
Erik Kratz pushed another run across with a sacrifice fly in the seventh.
Hamels, who retired 11 in a row during one stretch, allowed two hits in the first, third and seventh but pitched out of trouble each time.
NOTES: Austin Kearns had nine putouts in left field for the Marlins. ... Miami slugger Giancarlo Stanton saved a run and robbed Kratz of an extra-base hit in the second with a diving catch on the warning track in right-center. ... Marlins INF Nick Green was held out with a sore left thumb. ... Miami RHP Josh Johnson (7-8, 3.88 ERA) will face RHP Kyle Kendrick (4-9, 4.86) on Tuesday. Kendrick is 8-2 against the Marlins.