PHILADELPHIA — The marriage had been disjointed from the start, with the player dragging down the team. Jay Bruce and the Mets would come to know the agony of reaching a nadir, of being counted out, of feeling abandoned.

But at some point in the chaos of a wild-card chase, the relationship fundamentally shifted.

Few could have foreseen it, team and player together reaching the edge of redemption, as they did in Friday night’s 5-1 victory over the Phillies. Now within arm’s reach of salvaging a lost season, the Mets need only one more victory to clinch hosting the wild-card game against the Giants or Cardinals. They already have assured themselves of at least a tie for a wild-card spot.

“Each day is like Opening Day all over again,” Bruce said, optimism coating his description of October baseball, a vision that once had appeared improbable. “That’s why we play. We’re close to doing that.”

Acquired from the Reds at the trade deadline, Bruce on Friday night continued a late-season resurgence after a summer as a flop, knocking in three runs and homering for the third time in as many games.

Like the Mets — 60-62 and 5 1⁄2 games out of a playoff spot only six weeks ago — Bruce once looked like a lost cause.

Asdrubal Cabrera and Yoenis Cespedes returned from the disabled list, but both would play through pain the rest of the way. Second baseman Neil Walker went down for the year, putting even more of a spotlight on Bruce’s struggles. His average dipped to .174 as a Met. But those dark days now appear to be a memory.

advertisement | advertise on newsday

Ace Matt Harvey has long been lost for the season. Then Steven Matz and Jacob deGrom punched their tickets to the operating table. But the Mets have been bolstered by rookies Seth Lugo and Robert Gsellman.

With a slider that slashed through the strike zone, Gsellman held the Phillies to one run in six innings Friday night, delivering yet another unexpected dose of stability to a rotation clobbered by injuries. “This is what I dreamed of,” said Gsellman, who is 4-2 with a 2.42 ERA in his first eight big-league appearances.

Alec Asher retired the first 11 Mets batters and the Phillies gave him a 1-0 lead. But with two outs in the fourth, Cespedes and Curtis Granderson singled ahead of Bruce, who ripped the ninth pitch of his at-bat for a run-scoring single that tied it.

T.J. Rivera delivered an RBI single to left that drove in Granderson and put the Mets in front.

In the seventh, Bruce sent a solo shot over the leftfield fence. It was his fourth homer in his last six games.

Mets videos

As if to put a signature on the night, the wind gave the Phillies one more cruel blow in the eighth, turning a routine pop-up by Ces pedes into an adventure. A confused Ryan Howard let the ball hit just behind the first-base bag, opening the door for a two-run rally.

With their work finished for the night, the Mets had a chance to punch their ticket with a Cardinals loss. That game still was in progress when Jeurys Familia struck out Cody Asche to nail down the Mets' win. But according to Granderson, a consensus was reached. There would be no waiting anxiously for a Cardinals result to pop the champagne.

“We didn’t want to just sit around the locker room,” Granderson said, a decision validated when the Cardinals beat the Pirates, 7-0, after a rain delay.

By then, the clubhouse had emptied out, the players scattering into the Philadelphia night. In his office, manager Terry Collins fielded questions about the Mets’ remarkable journey. Since falling to two games below .500 on Aug. 19, they are 26-12. They remain one game ahead of the Giants for the top wild card and have a tiebreaker advantage over San Francisco.

Collins reached for his glasses and scanned his three-ring binder, opening to a sheet of color-coded matchups. He was assembling his starting lineup for Saturday.

advertisement | advertise on newsday

There once would have been a question about whether Bruce’s name would be in it. Not anymore.

“It’s not done yet,” he said. “But we are looking forward to controlling our own destiny.”