SAN FRANCISCO -- As the stragglers stumbled into the visitors' clubhouse, some New York Mets players hollered and high-fived teammates as they passed through the door.
This was just the kind of celebration that had escaped them before.
Eric Young Jr. scored on shortstop Brandon Crawford's fielding error with two outs in the 16th inning, and the Mets outlasted the San Francisco Giants 4-3 in a game that ended early Tuesday morning.
The Mets already had played three games of at least 15 innings this season -- and lost each one.
"I've never heard of anything like this. It's unbelievable," manager Terry Collins said. "At least we're used to it."
Young singled with one out and stole second to start the final rally. After he advanced to third on Daniel Murphy's groundout, lefty Javier Lopez entered and intentionally walked David Wright.
Crawford couldn't handle pinch-hitter Anthony Recker's grounder, allowing Young to score and handing New York the victory. The game lasted 5 hours, 26 minutes.
"We've played in some long games and we haven't always come out on the winning side," Recker said. "As soon as the 10th inning started, we were like, 'Are we really going to do this again?"'
It was the longest game in time and innings the Giants had played since losing 1-0 to the Arizona Diamondbacks in 18 innings on May 9, 2001.
Marco Scutaro walked leading off the bottom of the 16th inning, and Buster Posey hit a one-out single for the first five-hit game of his career. But Bobby Parnell regrouped to strike out Pablo Sandoval and retire pinch-hitter Guillermo Quiroz on a grounder for his 16th save.
Posey went 5 for 8, including a two-run homer and two doubles. San Francisco has lost 12 of 14 and is a season-high eight games below .500.
The Giants went 1 for 15 with runners in scoring position and stranded 18 overall -- 13 in the last six innings.
"That's as frustrating a game as we've had," manager Bruce Bochy said.
Tim Lincecum and Matt Harvey each threw seven innings of three-run ball before the bullpens shut down the opposition. Harvey said a blister on his right index finger has been bothering him his last two starts but he doesn't consider it an issue.
"I'm just glad we won," he said.
Josh Edgin (1-1) pitched two scoreless innings for the win. George Kontos (2-2) allowed the one unearned run in 2 2-3 otherwise solid innings.
It was the 18th major league game to go 14 innings or more this season, two shy of last year's total, according to STATS.
The Mets improved to 1-3 in games of at least 15 innings. The last team to play that many in one season was the 2004 Minnesota Twins, who went 2-2, according to STATS.
By the time the final out was recorded at 12:42 a.m. local time, only a few thousand fans remained from an announced sellout crowd of 41,497. The ferry back to Oakland-Alameda had blown its departing horn at 11:30 p.m., and the final BART trains left about midnight.
The Giants even held a 14th-inning stretch for those who stayed. So many seagulls started to hover above the stands that the scoreboard operator asked fans to clap to try and scare them away.
Both teams had chances to end the game earlier.
With runners on second and third in the 11th, Crawford made a diving stop on Marlon Byrd's grounder at shortstop and recovered for a perfect throw from the outfield grass. In the 12th, Sandoval snagged Omar Quintanilla's liner at third and threw to first to get Kirk Nieuwenhuis for a double play.
The Giants blew a gift-wrapped opportunity when Posey doubled after his fly ball bounced off the glove of Murphy backpedaling from second while Byrd tried to make a sliding catch coming in from right. Sandoval was intentionally walked before Byrd caught Hunter Pence's slicing liner and Crawford flied out.
Brandon Belt, batting in the third spot for the first time in his career, was 0 for 8 with five strikeouts, including the final out of the 12th inning with two runners on base. Bochy said he expects to keep Belt in that spot Tuesday night.
Cole Gillespie broke his bat grounding out in the 13th with runners on second and third, and Gregor Blanco grounded out with the bases loaded in the 15th.
Posey's 13th homer put the Giants ahead 2-0 in the first.
Byrd singled leading off the fifth for the first hit off Lincecum, and John Buck's double sliced San Francisco's lead to 2-1.
Young tripled leading off the sixth, and Murphy followed with the tying single. Murphy advanced to third on Scutaro's throwing error at second base and scored when Ike Davis grounded into a double play to give the Mets a 3-2 lead.
Lincecum had a season-high 11 strikeouts in seven innings. He gave up three runs, six hits and one walk. It was the 33rd time Lincecum has had at least 10 strikeouts in a game and the first time this year.
But the two-time NL Cy Young Award winner was nowhere to be found in the Giants' clubhouse after the game. A team spokesman said he had already left to recover -- as did many of his teammates.
Other than Posey, Harvey had his way with San Francisco's lineup until late. He allowed three runs and six hits, striking out six and walking one.
Pence, who made a pair of diving catches in right field, tripled leading off the seventh. The ball hit the cement near the top of the right-field wall and ricocheted back onto the field.
Umpires reviewed the play and ruled that the triple stood, though the decision turned out to be an afterthought. Crawford immediately singled home Pence for the tying run.
"There's frustration," Pence said. "We want to stay as positive as we can right now. We've got to get it done. We've got to keep pushing to find a way to turn it around."
NOTES: Posey will get Tuesday night's game off after catching 16 innings, Bochy said. ... Mets LHP Jonathon Niese (shoulder inflammation) has been cleared to start throwing again. The team expects him back at some point this season. ... Mets RHP Shaun Marcum had his right hand examined by a specialist in St. Louis. With an off day Thursday, Harvey is slated to take Marcum's spot in the rotation Saturday at Pittsburgh. ... Barry Zito (4-6, 4.44 ERA) starts for the Giants against Dillon Gee (6-7, 4.45) on Tuesday. Zito began warming up in the bullpen in the bottom of the 16th in case the Giants tied it.