It was ugly, disjointed and undisciplined, and then in one quick flick of Martin St. Louis’ wrists, all of the maladies faded.

What was left for the Rangers was pure bliss, a 3-2 overtime win over the Canadiens in Game 4 of the Eastern Conference final, and just one win between the Blueshirts and the Stanley Cup final.

“I’ve jumped on him a few times in overtime before,” said Brad Richards, “and it never gets old.”

Richards, teammates with St. Louis for seven seasons in Tampa Bay before being reunited at the trade deadline this March, and the Rangers, survived a playoff game with dire implications that was played as if both the teams were still thinking about all the verbal jousting that has become the underlying theme of the series.

But then six minutes into overtime, all of the crowd stood on its feet, all of the Rangers rose from the bench, and Carl Hagelin slid the puck across the ice to St. Louis, the future Hall of Famer left alone at the right dot.

“Right when I got it, I just saw their ‘D’ in front of me and I saw him chilling there on the right side,” Hagelin said from under the Broadway Hat. “It’s a great finish by him.”

A great finish indeed, one St. Louis practices “every time he’s on the ice, like a hundred pucks,” according to coach Alain Vigneault. Settling it down, picking the top-right corner, and giving the Rangers a commanding 3-1 lead in the best-of-seven contest, a chance to finish off The Yapping Habs on Tuesday night in the Bell Centre.

“This is far from over,” said Richards, the de facto captain, easily remembering how his Rangers came back from the same 3-1 deficit against the Penguins in the second round. “They will feel bad tonight, but tomorrow they will wake up in front of their home crowd and once that game starts, 3-1, you throw that out the window.”

What the Rangers can’t throw out the window is how this game was played, as they took nine minor penalties, giving the dangerous Montreal power play 14:33 of man-advantage time. Although there was the occasional embellishment on the part of the Canadiens, Vigneault was not looking to place blame anywhere outside his dressing room, knowing his team, predicated on discipline all season, has to be better if it wants to move on.

Carl Hagelin beats Dustin Tokarski in the first period.Photo: UPI

“It was us,” he said. “They were penalties. Can’t do that.”

All of the calls led to a game that was choppy and lacked flow, and the pressure to perform falling on the Rangers penalty kill, which was fearless in getting in front of shots from the likes of P.K. Subban and Andrei Markov, and had the steadying rock of Henrik Lundqvist in nets.

“We were definitely undisciplined,” said Hagelin, who got a shorthanded goal on a breakaway 7:18 into the first to take a 1-0 lead. “We took a few too many tripping and high-sticking calls. The refs are always going to call those. We have to play smarter.”

The Canadiens matched Hagelin’s goal 8:08 into the second, when Francis Bouillon made it 1-1 on a sharp wrister that beat Lundqvist high. Before the middle period ended, Derick Brassard, in his first game back from a two-game absence due to an upper-body injury, retook the lead with a breakaway slap shot, beating rookie goalie Dustin Tokarski, in the midst of another terrific performance.

Yet Subban got the lone power-play goal on a long deflected shot 2:00 into the third, tying it 2-2, allowing regulation to crawl to an end.

And then in overtime, well . . .

“I had a feeling going into the overtime, ‘OK, let’s not take another penalty,’ ” said Lundqvist. “And that’s what we do right away.”

Yet that Benoit Pouliot holding-the-stick was killed off, and allowed St. Louis to play the hero.

“It’s exciting to know that you’re one game away,” Lundqvist said, as Kings-Blackhawks plays out in the West final.

“You have to get to a level where you help the team, and that’s a pretty good motivation there.”

Will the Rangers finish off the Habs in Game 5?

The Rangers were fortunate to come away with a win . The game was indeed a sloppy performance. They can thank Lundqvist for holding everything together, the hustle of Brassard, Haglin and St. Louis for his pinpoint accuracy shot. The Rangers must stay disciplined to win game five but the series is far from over. Look at the Kings and the Ranger win comebacks being down 3-1 so if the Rangers let up, its feasible that Montreal can win the series. Praise to Vigneault for taking the high road during his interviews by saying the right thing and sending the right message . He is a smart coach with excellent media savvy. Lets also give credit to highly criticized Glen Sather for bringing in St. Louis and the steady, tough, under rated Kevin Kline. They would have not gone this far without those two.

@Benjamin Clark Trying to figure out if your glass is helf empty or half filled?....If this happens...if that happened....coulda .......if the clouds come out it might rain.....give them credit ...don't take away the accomplishments that came after all those mistakes. That's a sign of a good team.