It seemed as if it took a month, but the Rangers finally clinched the Eastern Conference’s first wild-card berth Sunday night. They likely will face the Montreal Canadiens in the first round of the Stanley Cup playoffs.

The Blueshirts, who already had clinched a playoff spot during their California trip, needed a point and got two against the Flyers, scoring four unanswered goals and holding on for a 4-3 victory. Equally satisfying, the win ended an eight-game losing streak at Madison Square Garden, which had been heavy baggage for the Blueshirts, who had last won on home ice on Feb. 17.

The Rangers have 100 points and are locked into a specific playoff spot, but they still need to work on their flaws.

“We’ve got to be playoff-ready when we get there,” said Mats Zuccarello, who tied a career high with three assists. “It’s hard to just turn on the switch.”

The Rangers were without injured captain Ryan McDonagh, but Zuccarello had his switch turned on, setting up the first three goals by Mika Zibanejad, Brendan Smith and Oscar Lindberg. Linemate Chris Kreider’s tip went past Flyers goalie Anthony Stolarz at 9:10 of the third period for a 4-1 lead.

But closing out the Flyers, who were eliminated from the playoff chase with the loss, wasn’t easy. Brayden Schenn and Valtteri Filppula scored two late goals in 51 seconds to make it interesting, and with 44.6 seconds to play and Stolarz pulled, Smith was penalized for interference. The Rangers fought off a six-on-four, though, as Henrik Lundqvist (20 saves) made a big glove stop on Claude Giroux with 15 seconds left.

advertisement | advertise on newsday

“For 58 minutes, we played a pretty good game. At the end, we had a couple opportunities to make the right play and we didn’t,” coach Alain Vigneault said. “They’re a real good team six-on-five and five-on-four, but at the end of the day, it’s about winning games. We may not be as sharp as I think we can be.”

The finish “was a good eye-opener for us,” said Derek Stepan, whose line, with Zuccarello and Kreider, produced six points. “Winning at home was something that the group understood was important to do.”

Filppula, carrying the puck in the left circle, waltzed into the slot and flipped a backhander past Lundqvist for a 1-0 lead just 33 seconds into the second. That gave Stolarz, 23, in only his third NHL start, something to work with, but the lead didn’t last long.

With Filppula off for holding Brady Skjei, Zuccarello’s pass found Zibanejad above the left circle, and with Kreider screening in front, the puck went through at 3:57 for a power-play goal and the tie.

Zuccarello later saw Smith driving to the net and fed him in stride, and Smith’s low backhand eluded Stolarz at 7:10. It was Smith’s first goal since he was acquired from the Red Wings at the trade deadline. Lindberg’s wrister on a rebound between the circles at 7:01 of the third provided a 3-1 edge.

The mindset now changes.

“We know we can’t just coast through our last three games and expect to be ready for game one on the road,” Dan Girardi said. “The results matter, but I think our 60-minute game, how we handle ourselves, how we handle the puck defensively, I think we’re more worried about that than the overall result.”

Stolarz, who is from Edison, New Jersey, had been summoned from the minors to back up goalie Michal Neuvirth on Saturday in Newark because Steve Mason had the flu. Stolarz was forced to step in during that game when Neuvirth collapsed during a play stoppage and was hospitalized.

Neuvirth was released from the hospital and was resting at home yesterday. Flyers general manager Ron Hextall said tests came back “normal.”