PARIS — Already boasting wins over Finland and Switzerland, France almost added the two-time defending champions to its impressive list of upsets at the world hockey championship.

Canada did just enough to sweat out a 3-2 win over France on Thursday, however, overcoming a boisterous home crowd and its own undisciplined play to remain perfect through four games in Paris.

The Canadians improved to 4-0 but faced plenty of adversity form the French. Canada fell behind an opponent for the first time in the tournament when Damien Fleury put France up 2-1 on the power play at the 1:37 mark of the second period.

Claude Giroux replied on a Canadian man advantage to send the teams to the dressing room in a 2-2 tie after two periods. Marc-Edouard Vlasic was credited with the winner at 2:22 of the third after a bouncing puck deflected past French netminder Florian Hardy off teammate Jonathan Janil.

France pressed for the equalizer behind a raucous sold-out crowd of 14,510 at AccorHotels Arena but Canada held on for the win.

"That game was really good for us as a coaching staff," said Canadian coach Jon Cooper after the game. "To come into a hostile environment, it was amazing to be in front of all those fans, knowing that a lot of them weren't cheering for us."

Canada's Ryan O'Reilly and France's Olivier Dame-Malka traded first-period goals.

Tempers ran high throughout the game. France was whistled for 10 minutes in penalties, while Canada received 33 minutes. Forward Jeff Skinner was assessed a major penalty and game misconduct for a spear on goaltender Hardy with 16:08 left to play in the third period.

"The refs have a tough job," Cooper said. "They've got to make split-second decisions and that's the way they saw it. Knowing Jeff Skinner, he didn't mean to do that."

Hardy made 32 saves for France, while Canadian goaltender Chad Johnson stopped 22 shots.

"It was a tough game for us," said Johnson. "They came hard and it seemed like any chance they had, they were close calls on a lot of them. As much as we controlled the puck, it seemed like whenever they had the puck, it was tough."

Canada was without Tyson Barrie, who had led all defencemen in scoring with seven points in three games before suffering a tournament-ending lower-body injury away from the ice on Wednesday.

Chris Lee, a 36-year-old from MacTier, Ont., was registered for the tournament on Thursday and took Barrie's place on the second defence pairing with Calvin de Haan and on the power play. Lee had 14 goals and 65 points in 2016-17 with Magnitogorsk Metallurg of the KHL. He had been a practice player with Canada and scored a goal during Canada's warmup game in Switzerland before the tournament began.

"It seems like a month ago now at this point," said Lee of his game experience with the team. "It's nice to get that one game just to kind of get a feel for the speed of the guys and the skill of the guys. Hopefully I can continue to get better as we move toward the medal round."

Lee came on Hockey Canada's radar at the Deutschland Cup last November but was a stranger to Cooper, who likes what he has seen.

"I've known Chris Lee for about 10 days," said Cooper. "It's been a good 10 days.

"He's savvy with the puck. He can calm things down. He's really good for our power play. He's just a consummate pro. He's been a great addition for us."

Another defenceman, Colton Parayko, had arrived in Paris after his St. Louis Blues were eliminated from the Stanley Cup playoffs, but was not yet ready for game action.

The two-time defending world champion Canadians remain first in Group B at 4-0. Earlier on Thursday in Paris, the Czech Republic shut out Norway 1-0.

In Group A action in Cologne, Germany, Russia moved into first place with a 3-0 shutout of Denmark, while Sweden beat Latvia 2-0.

Canada's next game will be against 2-1-1-0 Switzerland on Saturday.