Mike Pelfrey's pitch count and New York's shaky defense doomed the Mets on Sunday.

Pelfrey pitched six solid innings and departed with a one-run lead, but three Mets relievers allowed seven runs — only three of which were earned — in an 8-2 loss to the Philadelphia Phillies.

"Six innings is not what I'm going for," Pelfrey said. "Hopefully soon I'll be able to get through the whole game with 110 pitches."

The Mets were vying for their first three-game sweep in Philadelphia since June 2006 and they were in good shape after Ike Davis' two-run homer in the first gave New York a 2-0 lead against Cole Hamels.

But Laynce Nix hit a go-ahead double in the seventh and the Phillies scored five unearned runs in the eighth, highlighted by Ty Wigginton's three-run double, to help the five-time defending NL East champions avoid a sweep.

"We came in against the team everyone has favored to win the division and won two out of three," Mets manager Terry Collins said. "We'll have a sandwich and get ready for tomorrow."

Collins decided to pull Pelfrey for a pinch-hitter after the right-hander threw 99 pitches through six innings. He allowed eight hits while striking out two and walking two.

The Phillies went ahead in the seventh with two runs off Ramon Ramirez (1-1).

"He was outstanding," Collins said of Pelfrey, who has struggled in his career against Philadelphia. "It was another good start for him. He had a good curveball and got a lot of grounballs. He'd thrown 100 pitches and he was coming up to hit. I thought I'd get Ramirez in the game."

Ramirez was the victim of some bad luck in the seventh.

The Phillies tied it at 2 on Wigginton's sacrifice fly that scored Jimmy Rollins. Rollins could've been the second out of the inning, but Lucas Duda misjudged his lazy fly to short right field and the ball fell for a single.

"Lucas broke back on the ball," Collins said. "He probably had a shot."

Rollins moved to second on Hunter Pence's single, then both runners advanced on a wild pitch by Ramirez. Pence, incidentally, likely would have been the third out — his grounder into left field got through the hole between shortstop and third because shortstop Ruben Tejada was cheating up the middle.

Nix, who had been hitless in seven at-bats this season, doubled home Pence to put the Phillies up 3-2. Nix's hit nearly was caught by left fielder Scott Hairston, who charged into the corner and jumped for the ball but had it glance off his glove and ricochet into foul territory.

"I think it was a good time to get my first hit," Nix said. "I was happy to get my feet wet and get something done."

The Phillies, helped by Tejada's throwing error, tacked on five unearned runs run in the eighth, highlighted by Wigginton's bases-loaded double.

David Wright finished 2 for 4 to raise his average to .632. Davis and Duda each had two hits for the Mets, but left fielder Jason Bay was a late scratch. He injured his right ring finger sliding into a base Saturday night.

Hamels (1-1) struck out 10, walked one and allowed six hits in seven innings. Rollins and Pence each had a pair of hits for Philadelphia, which set a season high for runs and tied its season best with 14 hits.

NOTES: Each member of the Phillies and Mets honored the 65th anniversary of Jackie Robinson breaking the color barrier in baseball by wearing No. 42 during the game. During a pregame ceremony, members of the Tuskegee Airmen and two players from the Philadelphia Stars, Harold Gould and Mahlon Duckett, of the Negro League were recognized. ... The crowd of 45,829 was the sixth-largest in Citizens Bank Park history and the 210th straight regular-season sellout. ... It was the 19th career double-digit strikeout game for Hamels.