PHILADELPHIA - As the deciding 13th inning rolled on Thursday night, and the Mets put the finishing touches on a comeback that was more than four hours in the making, a chant could be made out from the smattering of fans in the stands.

Many of them wore orange and blue.

"Sweep! Sweep! Sweep!" they yelled, as the Mets beat the Phillies, 9-5.

The Mets maintained a 6 1/2-game lead over the Nationals in the NL East. They also completed their first four-game sweep of the Phillies since Sept. 2002.

Daniel Murphy capped a three-hit night, lacing a two-run double with one out in the 13th to put the Mets ahead for good.

Reliever Carlos Torres, who earned the victory with 21/3 innings of scoreless relief, had started the rally with his first big-league hit since 2013. The Mets tacked on two more runs thanks to errors by Phillies reliever Hector Neris and an RBI single by Michael Conforto.

The Mets, who had struggled away from Citi Field, went 8-1 during a road trip that featured a split with the Orioles followed by sweeps of the Rockies and Phillies. In that span, the Mets clubbed 23 homers while averaging 9.1 runs per game.

For second time in the series, the Mets' power display rallied them from a five-run deficit.

Down 5-0 in fourth, the uprising began with Travis d'Arnaud's two-run homer over the rightfield fence.

The homer gave the Mets 41 in the month of August -- the most prolific power month in the history of the franchise.

But they weren't through.

Cespedes followed in the fifth with a two-run homer that landed in the Phillies bullpen, just right of straightaway centerfield.

The prodigious blast was Cespedes' sixth homer in his last seven games, and his eighth overall since the Mets acquired him from the Tigers.

Kelly Johnson completed the comeback two batters later, when his solo shot tied it at 5.

With their latest home-run binge, the Mets effectively erased a horrendous third inning for Jon Niese. In just one frame, he surrendered five runs.

Jeff Francoeur ambushed Niese after a mound meeting, lining the first pitch he saw to knock in a pair of runs. Later, Darin Ruf hit a two-run homer to cap off the five-run flourish.

But despite his nightmarish inning, Niese regrouped and pitched through the sixth inning. The lefty worked with iffy command, walking five while plunking a batter. But he also struck out five and did not allow a run after the third. His efforts loomed large later on.

Murphy led off the Mets' half of the ninth with his second hit of the game. But from first base, Murphy watched as David Wright lined out, Johnson flied out to the warning track, and d'Arnaud looked at a called third strike.

In the 10th, the Mets survived a scare when Phillies pinch-hitter Domonic Brown just missed a walk-off homer, buzzing the wrong side of the rightfield foul pole. The Mets got out of the inning with a bizarre entry into the highlight reel.

Torres used his leg to re-direct Francoeur's hard comebacker toward first base. Murphy dived to his left to field the ricochet, then made a backhanded throw from his knees to hit a sprinting Torres as he covered first base. Torres beat Francoeur by half a step.