Four batters before Kirk Nieuwenhuis ended the Mets' oddball 4-3 victory Sunday over the Cubs by belting a three-run home run, jumping on home plate and taking an apple pie in the face, Marlon Byrd rapped an upper-deck homer that looked as if it would only prevent a shutout.

But maybe not.

Kirk Nieuwenhuis celebrates as he approaches the plate after hitting a game-winning home run off Chicago Cubs reliever Carlos Marmol on Sunday. Associated Press

Terry Collins, the manager of a team that appeared all but doomed to lose its fourth straight game and 11th in 13 games, said he felt "a huge, huge bolt of energy go through the bench." Then he actually heard someone say the Mets were going to win.

"I didn't know how," Collins said.

About 90 minutes after the Mets gave up two runs on a can't-anybody-here-play-this-game fifth-inning play in which they made two errors and nearly made a third, the Mets actually thought they had a chance. The Cubs still had three outs to get. They got one.

Nieuwenhuis, batting .097 at the time and already having gone 0-for-2 with a walk, nailed his first homer of the season by drilling an 0-1 fastball from Chicago reliever Carlos Marmol off the facing of the upper deck in right field. It was the first walk-off homer of Nieuwenhuis's career.

He said the apple pie tasted great, then said, "I was waiting for the whipped cream."

But Byrd's leadoff blast in the ninth inning off Marmol apparently served as the catalyst. Marmol, who is notably erratic and lost his job as the Cubs' closer earlier this season, walked Lucas Duda (hitting .226) and gave up a single to John Buck (hitting .191 since May 5) before Omar Quintanilla's sacrifice bunt.

"We knew we had a couple of opportunities with runners in scoring position, and we just couldn't get that one, breakthrough hit," Mets third baseman David Wright said. "After Marlon got that one, it kind of allowed everybody to kind of go up there and take a deep breath and go up there and have at-bats instead of maybe doing a little much.

"It relaxed the dugout a little bit. Most important, it gave everybody confidence. Maybe from the outside, you think, 'Big deal, 3-1.' But you have that hit, and everybody else says, 'Marlon had a good at-bat, he hit a ball into the second deck. That gives me confidence going in there.' That's exactly what it did."

After the game, Byrd stood in the Mets' clubhouse and said, "The big thing is that we're going to Atlanta with a win instead of being swept." But before heroics from Byrd and Nieuwenhuis, the Mets had been on the way toward dropping a game that included a play that was hilarious to everyone but them.

Trailing in the fifth, 1-0, and with two outs and a 1-2 count on Alfonso Soriano, Mets starter Jeremy Hefner gave up a hard grounder that Wright dove to stop. He looked to second base for a force out, but he had no play there, so he flipped to first base.

"It kind of set things into a mad scramble," Wright said.

His throw sailed over Daniel Murphy's head. Murphy tracked down the ball and tried to throw out Starlin Castro at home, but his throw sailed wide of Buck, the catcher. Nate Schierholtz scored. The ball bounced off the backstop, and Quintanilla retrieved it.

Quintanilla tried to throw it to Buck, but his throw also sailed wide, leaving Buck looking like he'd just done a double axel. Murphy backed up the play and prevented Soriano from scampering home with what a Little League mom would have scored as a home run. Hefner got the third out but was done for the day.

"I didn't directly have an involvement in that, but it was partly my fault," said Hefner, who watched most of the play from next to the mound, then nearly ran into Schierholtz while trying to back up home plate.

Hefner received a mock cheer from most of the 30,256 at Citi Field for retiring Anthony Rizzo on a comebacker, but he'd gotten out of the inning. Collins told Hefner he was taking him out after 87 pitches. The Mets suddenly needed a lot of offense.

They had three hits entering the ninth inning, but Carlos Torres, David Aardsma and Bobby Parnell pitched well in relief for the Mets, allowing no runs. Then Byrd stepped to the same plate where Buck had been so comically spun around four innings earlier.

"If we can't use this as a spark, I mean, I don't know what else we can do," Collins said.

Byrd said of the victory, "It was much-needed. We needed something."