Nothing comes easy for the Mets in Philadelphia.
Martinez pitched effectively into the sixth inning and then watched the Mets give back nearly all of a nine-run lead before holding on for a 10-9 victory over the Phillies on Monday night.
"I was going, 'Wow, what's going on,'" said Mets manager Jerry Manuel, who was ejected in the seventh inning on a disputed home run call.
The Mets had a 10-7 lead heading into the ninth, but Wagner, who blew a save in the Mets' win Sunday, gave up a two-out RBI single to Pedro Feliz, scoring Shane Victorino. Eric Bruntlett, who had walked, also came around to score on a throwing error by center fielder Carlos Beltran. Jayson Werth hit a soft liner to right, ending the comeback and giving Wagner his 20th save in 26 opportunities.
"You can never let down with this team," Wagner said. "They make you earn it."
Endy Chavez, Damion Easley and Fernando Tatis had three hits each for the Mets (45-44), who last had a winning record on June 5 (30-29). New York tied its season high with 17 hits and wound up taking three of the last four games from the Phillies to move within 2½ games of the NL East leaders. The Mets haven't been 2½ games out of first place since May 20.
"Were back in the race," Manuel said.
Martinez (3-2) turned in one of his more effective performances of the season by allowing only five hits and two earned runs in 5 1/3 innings.
"I got a lot of breaks and got a big lead early," Martinez said. "That gives you confidence. Just get it over and pretty soon they're swinging at everything you throw."
Philadelphia right-hander Adam Eaton (3-7) entered the game with a 5-0 career record against the Mets, but he was touched for 10 hits and eight runs -- six earned -- in 2 2/3 innings, his shortest outing of the season.
"I either pitch well or I pitch bad," Eaton said. "I can't seem to get something in between."
The Mets scored two runs in the first and three apiece in the second and third to take an 8-0 lead.
Chase Utley, Pat Burrell, Ryan Howard and Geoff Jenkins homered for the Phillies, who swept the Braves on the road for the second time this season and won the opener against the Mets before dropping three in a row.
"We keep battling and keep fighting," Philadelphia manager Charlie Manuel said. "When you're trying to catch up from a big deficit, it's hard."
Utley hit a solo homer in the fourth, his major league-leading 25th of the season, which cut the lead to 8-1.
Wright spoiled the major-league debut of Philadelphia reliever R.J. Swindle on his 25th birthday with a solo homer to left, leading off the sixth. Burrell added a solo shot in the sixth, his 22nd of the season.
Howard hit a two-run homer to right in the seventh off Tony Armas, which was initially called a ground-rule double because a fan reached over the right-field wall and touched the ball. The four umpires convened and ruled the ball would have left the park had the fan not interfered. Television replays were inconclusive.
Manuel disputed the reversal and was ejected.
"It was not a home run," he said. "It seemed like nobody really knew what it was."
Manuel was also ejected -- as the Mets bench coach -- earlier in the season when the umpires overturned a homer by Carlos Delgado at Yankee Stadium.
Howard's homer made it 10-5.
Jenkins had a pinch-hit two-run homer in the eighth off Aaron Heilman. It was the second pinch homer this season for Jenkins, who snapped an 0-for-11 streak.
Easley extended his hitting streak to nine with an RBI single in the first. ... Howard singled in the second, upping his hitting streak to a season-high 10. ... Philadelphia right-hander Brett Myers made his second start for Triple-A Lehigh Valley, giving up seven hits and three runs -- two earned -- in 7 1/3 innings. He struck out six and walked two. ... Jimmy Rollins stole his 36th consecutive base in the fifth, dating to Aug. 31, 2007. He's 22-for-22 this season.