Rangers head coach Alain Vigneault walks off the ice after...

Rangers head coach Alain Vigneault walks off the ice after a 2-1 loss to the Islanders at Barclays Center on Thursday. Credit: Kathleen Malone-Van Dyke

Hours after ending their season with a 5-0 loss to the Flyers in Philadelphia, the Rangers fired coach Alain Vigneault on Saturday night.

They made the announcement moments after TSN’s Bob McKenzie tweeted that Vig neault had been sacked after five seasons with the team.

Hours earlier, in Vigneault’s postgame media briefing, he made an impassioned defense of his record and said he expected to stay on as coach.

“Yes, yes. Without a doubt,’’ he said when asked if he thought he would hold on to his job despite the Rangers’ 34-39-9 record, which caused them to miss the playoffs for only the second time since the NHL lockout that canceled the 2004-05 season. “I think my staff is the right staff for this job. I think — and this is just my opinion — but I think one of the strongest assets of this organization is its coaching staff and their experience.’’

Vigneault guided the team to the Stanley Cup Final in 2013-14, his first season as coach. It was his second trip to the Cup Final; his Vancouver Canucks had lost in Game 7 in 2011. He has a record of 648-435-98 as a head coach for Montreal, Vancouver and the Rangers and won the Jack Adams Award as Coach of the Year in 2007 with Vancouver.

Vigneault, who went 226-147-37 with the Rangers, signed a three-year contract extension midway through last season that has two years left on it. But in early February — after a slow start put the Rangers in a deep hole — the club’s management determined that it was time to give up on chasing a playoff spot. They announced the decision to rebuild the team for the long term in a letter to the fans on Feb. 8, when the Rangers were three points out of a playoff spot with 28 games to play.

After the Rangers were officially eliminated from playoff contention, Vigneault told reporters on March 28 that he thought the Rangers would have made the playoffs had they kept the team together and not traded Nick Holden, Michael Grabner, Rick Nash, J.T. Miller and Ryan McDonagh, the captain.

In his postgame media address Saturday, Vigneault essentially said he had done the best he could with what he had to work with this season.

“At the end of the day, for coaches, you have to coach the team that you have in front of you,’’ he said in a four-minute soliloquy. “You try and put a system in place that maximizes their talent level, and you try and mask or hide the weaknesses and you work on both areas so that your team can improve.’’

He went on to detail his successes with Montreal and Vancouver, noting that in the five years since he left Vancouver, the Canucks are on their third different coaching regime.

“Probably coaching might not have been one of the main [problem] areas,’’ he said.

Vigneault said at the time that he had not spoken to general manager Jeff Gorton about his future with the team. “Every year you do your season, and at the end of the season, you sit down and you talk and you analyze and you work on getting better,’’ he said, “and I didn’t think this year was going to be any different.’’

Notes & quotes: Claude Giroux had a hat trick for the Flyers, who outshot the Rangers 40-17 and clinched a playoff spot . . . The Flyers scored six seconds apart in the second period when Giroux followed up a goal by Michael Raffl . . . The Rangers assigned rookies Lias Andersson and Filip Chytil and Steven Fogarty — who had been called up for Saturday’s game — to AHL Hartford.

More Rangers