Ferrari's Sebastian Vettel beat Lewis Hamilton's Mercedes to pole position at the Canadian Grand Prix.
It was only the second time in seven races Mercedes have been beaten to pole - the other by Vettel's team-mate Charles Leclerc in Bahrain in March.
Vettel was 0.206 seconds quicker than Hamilton, with Leclerc 0.680secs off.
Daniel Ricciardo was a surprise fourth for Renault after Red Bull's Max Verstappen was caught out by a crash by Kevin Magnussen in the second session.
Hamilton had been quickest on the first runs in the top 10 shoot-out, by nearly 0.2secs from Vettel, but the German four-time champion pulled out a special lap on his final run.
Vettel whooped with delight over the radio as he took his first pole position since last year's German Grand Prix in July.
Leclerc, who had been swapping fastest times with Vettel for much of the weekend and in the first two parts of qualifying, said he struggled with the car's balance when it mattered, and had also made two mistakes.
Mercedes driver Valtteri Bottas will start sixth after a spin on his first lap and then a scrappy lap on his second attempt.
Hamilton currently leads Bottas by 17 points in the drivers' championship.
- Canadian Grand Prix qualifying results
- Chequered Flag podcast: What would you have on chips in Canada?
- Lucky seven? Or will Hamilton end up in 'wall of champions'?
How are Ferrari suddenly quick again?
Mercedes had said before the weekend that they expected a strong challenge from Ferrari on Montreal's Circuit Gilles Villeneuve.
It was a claim met with scepticism in some quarters but it was founded in an understanding that Ferrari have had a straight-line speed advantage all year - and this track layout rewards that like few others.
Hamilton explained that Ferrari were gaining 0.5secs on the straights on overall lap time; the Mercedes has different characteristics as a car. Their car's strengths are in cornering speed, while the Ferrari has less drag and downforce in addition to the most powerful engine.
The race, though, might be a different matter. Ferrari's straight-line speed advantage is not as pronounced in race trim and a close battle is expected.
However, Mercedes go into the race with concerns after one of their new specification engines, which are fitted to the factory team's cars and those of both customers, failed in Lance Stroll's Racing Point in final practice.
What a day for Renault
The story of the day was arguably Ricciardo's brilliant fourth place, and the fact he pipped Red Bull's Pierre Gasly for the position will be especially sweet, after so many questioned the Australian's decision to leave Red Bull for Renault this season.
Ricciardo was 0.008secs ahead of Gasly, as Red Bull were left to rue a strategic error in second qualifying.
Attempting to complete that session on the more durable medium tyre so they could start the race on it - as Ferrari and Mercedes did - Verstappen was not quick enough. He sits ninth on the grid as Magnussen will start from the pitlane following his crash.
At Renault, Nico Hulkenberg also made it into the top 10 in seventh place, 0.253secs slower than Ricciardo.
He headed the McLaren of Lando Norris - another impressive showing by the 19-year-old British rookie. Norris' team-mate Carlos Sainz had qualified just behind, but was subsequently handed a three-place grid penalty for blocking Anglo-Thai novice Alexander Albon.
Toro Rosso's Albon was 14th, two places behind team-mate Daniil Kvyat, and British rookie George Russell made it 7-0 in qualifying against his team-mate Robert Kubica in 19th place in the private Williams battle, Russell 0.776secs ahead.
What they said
Sebastian Vettel: "I'm full of adrenaline. You know what, the feeling in the car when it just keeps coming and the feeling - it felt so good. I enjoyed it and I'm very happy and happy for the team over the last few races, it's been very tough."
Lewis Hamilton: "I don't feel disappointment, we gave it everything I had got. They were faster and in the last sector they were killing us, the timing was right, procedures were perfect, we had P1 for a second, but we knew they were quick."
Charles Leclerc: "I don't really know, I struggled with the car and with the set-up. I struggled with Q1 so I need to work with that on trying to have the right set up for the final Q3 time. Congratulations to Seb he deserves it and hopefully I'll have a better race from my side tomorrow."
Daniel Ricciardo: "June 8 is a good day for me. Five years ago today I got my first win here. Today was kind crazy in a way to end up fourth. But through qualifying it really looked like we had the pace. Gasly was only 0.4secs up the road and we thought Gasly was a realistic target. Did we think that would put us fourth and only 0.1secs from Leclerc? Not really. It's just an accumulation of spending time with the team, feeling more at home with the car and getting more on top of the differences between this car and the Red Bull."