MONTREAL — A modest two-game winning run has the Montreal Canadiens dreaming of turning their woeful season around.

Brendan Gallagher scored in the third period after the Vancouver Canucks had fought back to tie the game to lift the Canadiens to a 5-2 victory on Sunday night. It was a second win in a row following a five-game losing slide for Montreal (18-20-4), which needs to battle past five teams for a chance to snag a wild card playoff spot.

“We’re starting to feel a bit better for ourselves, mentally,” said Gallagher. “Some pucks went in, which was nice, but the chances have been there of late.

“We have a tough grind ahead of us for the rest of the year, but I think we’re all up to the challenge. It’s going to be fun if we can get a few wins and get ourselves back closer and really put some pressure on those teams.”

Karl Alzner, Alex Galchenyuk, Paul Byron and Max Pacioretty also scored for the Canadiens, who had scored only five goals in their previous six games. Montreal was coming off a 2-1 shootout win over Tampa Bay on Thursday.

Daniel Sedin and Michael Del Zotto scored for Vancouver (16-20-5), which was playing a second game in as many nights after opening a seven-game road trip with a shootout loss in Toronto on Saturday.

“It’s not an excuse — teams play back to back all year,” said Canucks forward Sam Gagner, whose team is 2-10-2 in its last 14 games. “We’ve done some good things, but obviously when you look at our record over the last couple of weeks, we have to find a way to push through.

“Tonight we were a little soft on the puck at times and it ended up costing us. We’ve got to be better.”

Montreal outshot the Canucks 45-36, although shots were 17-17 in the third period.

Before the game, Canadiens general manager Marc Bergevin said he was not yet ready to throw in the towel and start making trades with an eye to next season. He believes the club can still make the playoffs with a major second-half push, although they would likely need to win two-thirds of their remaining games just to have a chance.

“We’re just over the halfway point and it’s important for us to focus on the second half,” said Gallagher. “We’re certainly not out of it, but we can’t afford to have any more losing streaks or lulls in our game.

“If we can keep collecting points, it’s going to be tough, but we’ve taken a good step towards it in these last couple of games.”

Alzner shot on a rush up the left side and saw it go in off some traffic in front of Anders Nilsson for his first in 42 games as a Canadien and his 20th in 633 career NHL games.

Galchenyuk one-timed a Jeff Petry pass inside the far post from the right circle on a power play 2:12 into the second frame.

But tired legs or not, the Canucks battled back to tie it.

A Jonathan Drouin giveaway in the Vancouver end saw a quick counterattack on which Daniel Sedin sent Brock Boeser in on a two-on-one to feed Del Zotto. The defenceman got his second of the season on the backhand 2:47 into the third. Boeser picked up his 10th point in the last eight games.

But Gallagher was in the slot to pick up the rebound of Alzner’s shot and beat Nilsson with a high shot for the game-winner at 8:44. He then fed Byron on a rush for a goal at 18:45 before Pacioretty added an empty-net goal at 19:01.

As expected, defenceman Chris Tanev sat out after taking a puck to the mouth and losing some teeth in Toronto. Ben Hutton took his spot. Forward Sven Baertschi was back in the Canuck’s lineup after missing 11 games with a broken jaw.

Vancouver’s next stop is Washington on Tuesday. Montreal begins its bye time — four full days off — on Monday. The Canadiens next play Boston at home on Saturday.

Defenceman Victor Mete will rejoin the Canadiens on Friday after helping Canada to gold at the world junior championship. Bergevin said Mete will “probably” spend the rest of the season in Montreal.