"It's always hard. I felt like I was in command of the game -- and all of a sudden, in two pitches, I lost it," Martinez said. "It was a little bit frustrating. I did whatever possible to give my team an opportunity to win, and I blew it at the end. No excuses. They battled and never gave up."
Martinez (12-5) struck out five, walked one and retired 20 consecutive batters before Perez drove his 86th pitch off the left-center fence on a 1-1 count.
It would have taken a spectacular play for 39-year-old Gerald Williams to catch Perez's long drive. He ran full speed to the warning track, then pulled back at the last moment as he crashed shoulder-first into the wall and the ball bounced away.
"Perez hit that ball, but it wasn't like he actually knew what was coming," Martinez said. "He just reacted to it, threw the head of the bat on it and it hit the wall. I made the pitch I wanted to, and he happened to hit it. He's a strong kid."
Williams was in center field for this series only because the Mets' two best defensive outfielders -- Gold Glove winner Mike Cameron and All-Star Carlos Beltran -- were injured in a head-to-head collision Thursday at San Diego.
Werth sent the crowd of 48,055 into a frenzy with a drive into the pavilion seats in left-center on a 1-1 pitch for his sixth home run.
"It was a fastball up and in," Martinez said. "We were playing the infield in, so I was trying to keep him in the infield. But he cheated a little bit and got to it."
Brad Penny (6-7) hung on at the finish for his first win in seven starts. The right-hander scattered 10 hits in his first complete game with the Dodgers and third in 155 career starts. He struck out nine and walked none while going the distance for the first time since April 4, 2002, with Florida.
New York threatened in the ninth when Marlon Anderson doubled with one out and stole third. He tried to score on Victor Diaz's slow bouncer with the infield in, but was tagged out by Dioner Navarro after a perfect throw from second baseman Perez. Penny struck out pinch-hitter Kaz Matsui to end it.
Martinez merely sat on the bench by himself after the final out. As the Dodgers celebrated on the field, he received pats of encouragement from manager Willie Randolph and several teammates as they cleared the dugout.
After a few minutes, Martinez stood up and made his way to the clubhouse. The complete game was the third this season for the seven-time All-Star.
"He had some good stuff going, obviously, to take a no-hitter that deep into the game," Werth said. "And with us getting to him that late in the game, it's one of the better wins I've been a part of."
A three-time Cy Young award winner, Martinez helped Boston win the World Series last season. That title left him with most everything on his resume except a no-hitter -- though he did his best to get one 10 years ago.
On June 3, 1995, Martinez pitched nine perfect innings for Montreal at San Diego. But the teams were scoreless going into extra innings, and Martinez gave up a leadoff double to Bip Roberts in the 10th. In baseball's official records, Martinez did not get credit for a perfect game or a no-hitter.
Now in his first season with the Mets, Martinez also took a no-hit bid into the seventh inning against Houston on June 7 at Shea Stadium before Chris Burke hit his first major-league home run.
The Mets' only run came on consecutive doubles by Diaz and Williams in the fifth.
The 33-year-old Martinez has three one-hitters, the most recent on Aug. 29, 2000, when he beat Tampa Bay 8-0 with Boston.
"If a no-hitter comes, I'll take it," said Martinez, whose brother Ramon pitched one for the Dodgers against Florida in 1995. "I don't go out there expecting no-hitters, but I was lucky enough to be flirting with a no-hitter today. I'm just proud I was able to come here and show the fans what I didn't have enough time to show them before."
Martinez began his big-league career with the Dodgers in 1992 as a reliever before he was traded to Montreal in November '93 for Delino DeShields. From there, the wispy right-hander with the powerful fastball went on to win five ERA titles.
Dodgers executive Tommy Lasorda, who was managing the club when Martinez broke in, didn't have any room in his rotation for the right-hander. Lasorda watched Martinez flirt with history Sunday as he sat in owner Frank McCourt's field-level seats during the game.
"I didn't want him to pitch a no-hitter and I didn't want him to beat us," Lasorda said as he left the Dodgers' clubhouse. "And I said, `This is the inning.' Not only was the no-hitter broken, but the shutout was gone and it was a tremendous win."
A ballboy on the right-field line tried to backhand Cliff Floyd's fourth-inning double and missed it, forcing umpire Brian Gorman to signal that the ball was still alive.