It marks the second time in franchise history that the Mets (87-74) will appear in the postseason in consecutive years. They earned consecutive wild-card berths in 1999 and 2000.

"It's just great to see the team this year accomplish as much as it did with as many obstacles placed in its path that they had to negotiate," general manager Sandy Alderson said.

After James Loney slugged a tiebreaking two-run homer and Jeurys Familia notched his 51st save, the Mets doused one another with champagne in the visitors' clubhouse. The players then spilled onto the field to celebrate with a sizable contingent of Mets fans who had invaded Citizens Bank Park.

The Mets high-fived spectators who congregated down the third-base line. The Phillies placed a message on the scoreboard that read: "Congratulations to the New York Mets on securing a wild card berth in the 2016 MLB postseason."

Loney's homer against David Hernandez in the sixth inning, which was followed by a prodigious bat flip, had staked the Mets to a 4-2 lead. Philadelphia pulled within a run an inning later on pinch hitter Darin Ruf's solo homer against Fernando Salas, but the Mets added an insurance run and Familia overcame a two-out baserunner in the ninth.

The normally reserved Loney laughed off his bat flip in the clubhouse afterward, saying: "I don't know if I just dropped it or I flipped it or what. That's nothing ever toward the other team. That's just for your team. That's the excitement that you have. As a hitter, you get out a lot. So there's times in those big moments it's fun to enjoy it."

"This game is about pitching," manager Terry Collins said. "It tells you that this organization has done a tremendous job of stockpiling some pretty good pitching. We traded a bunch of them last year to get us to the World Series, and yet we still had Gsellman and Lugo and guys that have come in this year and saved us -- just literally saved us -- with all of the injuries we've had to our pitching."

Syndergaard will start Wednesday's wild-card game against the Giants or Cardinals. Which team he will face will not be determined until Sunday at the earliest and may require a play-in game Monday at Busch Stadium.

"I think it's like every little kids' dream come true to pitch in a high-stakes game," Syndergaard said. "I'll embrace it. I'll look forward to it. It should be a lot of fun."

The Mets had a 60-62 record on Aug. 19 after dropping a second straight game in San Francisco, leading to questions about Collins' future. Falling two games under .500 coincided with the returns of Yoenis Cespedes and Asdrubal Cabrera from the disabled list. Since that point, the Mets have posted the best record in baseball and now are a season-high 13 games over .500.

Alderson remade the roster on the fly as the Mets dealt with mounting injuries. Jose Reyes' signing after a domestic-violence incident prompted his release by the Colorado Rockies offset the loss of David Wright due to a ruptured disk in his neck. The addition of Loney, who had been languishing in Triple-A with the San Diego Padres, stabilized first base after Lucas Duda was diagnosed with a stress fracture in his lower back that ultimately sidelined him for four months.

Alderson's signature trade-deadline acquisition was right fielder Jay Bruce from the Cincinnati Reds for second baseman Dilson Herrera and minor league left-hander Max Wotell. Unlike a year ago, when Cespedes' acquisition helped the Mets become the first team in MLB history to reach the World Series after ranking last in the majors in runs scored on July 31, Bruce struggled for much of the season's final two months. He has homered four times since Sept. 24 and shown signs of awakening at the right time.

Collins said he is particularly proud of the Mets' resiliency in the wake of injuries.

"You can hit yourself in the head so many times before you start to say, 'Geez, it's just not going to happen.' And these guys never stopped," Collins said. "They just kept coming every day and played no matter who was out. You get kind of numb to the situation -- 'Hey look, somebody's out.' Well, somebody else has got to play there. They've just kept grinding it out."