The way Philadelphia's Cole Hamels was pitching, it was going to take a near perfect outing from Miami's Nathan Eovaldi to earn a victory.

Eovaldi (3-8) was far from perfect as he allowed three runs — two earned — and eight hits in five innings for the Marlins, who lost 4-0 to the Phillies behind a second consecutive shutout by Hamels (13-6).

"He got lucky they didn't score more runs," Marlins manager Ozzie Guillen said. "They could have had a big, big, big inning. He pitched just good enough to not let them score that many runs."

The Marlins have lost four of five.

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 as he lowered his ERA to 2.91.

"Cole Hamels was pretty good today, very good," Guillen said. "His cutter was outstanding, his changeup was working. We faced one of the best lefties in the game. When it's going that way, you know it's going to be a tough night to handle offensively."

It was the first time Hamels tossed consecutive shutouts. The last Phillies pitcher to accomplish the feat was Cliff Lee, who had three straight in June 2011.

"I haven't had (shutouts) in a couple years, they're nice to be able to do," Hamels said. "I watched Cliff be able to do it last year with the consecutive shutouts he's throwing and it makes you believe, 'Why can't you do it too?'"

Hamels entered with an 0-3 record and 5.21 ERA in three outings against the Marlins this season.

"Obviously I haven't done too well against them recently, but it's just a matter of making pitches, hitting the target, and being precise with it," Hamels said. "I feel healthy and confident in all four pitches."

In his three August starts, Hamels is 2-1 with a 0.72 ERA. He has struck out 20 and walked two.

"Are you expecting complete game shutouts the entire time, no, but watching Cole for all of these years and playing against him, he's capable of doing that every time," Phillies third baseman Kevin Frandsen said.

Juan Pierre had three hits and Jimmy Rollins scored twice for the Phillies, who snapped a five-game losing streak against Miami.

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.

"I missed a couple of spots with Rollins and Pierre," Eovaldi said.

Erik Kratz pushed another run across with a sacrifice fly in the seventh.

Hamels, who retired 11 straight 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. ... Rollins tied Larry Bowa for most games played at shortstop in Phillies history with 1,730. ... 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.