Sophie Schmidt's second-half goal sent Canada into the Olympic women's soccer semifinals on Friday with a 1-0 win over favoured France.
The 10th-ranked Canadian women are now one win from climbing the medal podium in back-to-back Games. They won bronze four years ago, defeating France by the same score.
The Canadians rushed off the bench to celebrate after the whistle blew on a tense final passage.
Canada is 4-0-0 in Brazil and has dispatched three top-10 teams in No. 2 Germany, No. 3 France and No. 5 Australia. John Herdman's team is on a roll.
Canada will play Germany again on Tuesday in Belo Horizonte. The Germans beat No. 12 China 1-0.
Sixth-ranked Sweden will play either No. 5 Australia or No. 8 Brazil in the other semifinal in Rio.
The Swedes opened the day with a bang, upsetting the top-ranked Americans 4-3 in a penalty shootout after the game ended 1-1 after extra time. The Americans, who had been unbeaten in 18 matches (16-0-2) this year, had won four of the five previous Olympics including the last three. They were runner-up in the other.
On Friday, the Canadians held it together during difficult times and then opportunistically took advantage of a rare scoring chance.
France had more of the play but Canada went ahead in the 56th minute when Janine Beckie, showing real skill in controlling the ball, chipped a cross over to Schmidt who acrobatically knocked it in from close range.
Two minutes later, there was a scare at the other end when Christine Sinclair's defensive header off a French free kick hit the Canadian crossbar. And it was Beckie to the rescue in the 71st minute when she headed the ball away from in front of an empty goal.
The French kept coming as a tense Herdman watched from his technical area. There was some desperate defending before it was all over.
Schmidt left in the 81st minute to applause as defender Rebecca Quinn was brought on to stiffen the Canadian defence.
Goalkeeper Stephanie Labbe did her part as the French looked to find their big targets in the box.
It was a chilly evening at Corinthians Arena. Despite the temperature, the crowd of 38,688 was enthusiastic and had the wave going within six minutes of kickoff.
Both teams had trouble building an attack in the early going. Canada lived dangerously by giving the ball away, allowing the skilled French to stroke the ball around, probing and pulling the Canadian defence.
France thought it should have had a penalty in the 10th minute when Eugenie Le Sommer went down on a Kadeisha Buchanan challenge. Uruguayan referee Claudia Umpierrez disagreed but replays showed contact was made.
Beckie sent in a dangerous cross in a rare Canadian attack in the 23rd minute after a nice Sinclair through ball but the ball was knocked away.
French defender Griedge Mbock Bathy then just missed with a header off a free kick in the 29th minute.
The Canadians seemed to find their stride as the first half wore on, stringing passes together. But they lost fullback Allysha Chapman late in the half to injury when she was flattened by a French attacker. She was replaced by Josee Belanger. And the half ended with French captain Wendie Renard sending a header off a corner just wide of the goalpost.
There was more of the same in the second half, with the French again threatening off set pieces. But the Canadians defended doggedly and waited for their chance.
Players on both sides lost their footing on the Corinthians Arena pitch throughout the game.
Canada won all three preliminary-round games, including a victory over No. 93 Zimbabwe. The French beat No. 17 New Zealand and No. 24 Colombia but lost to the U.S.
Coming into the game, Canada's all-time record against the French was 4-5-3 although it had only won once in the last eight meetings (1-4-3) dating back a decade. That win, courtesy of a Diana Matheson goal in stoppage time after a game in which the French dominated, was for the bronze four years ago.
Belanger, Jessie Fleming, Nichelle Prince and Rhian Wilkinson came into Friday's game on yellow cards, meaning they were one caution away from a one-game suspension. Only Fleming started.