Kevin Magnussen has taken a sensational first career Formula One pole position, in his 100th race for the Haas team, after Friday qualifying for the sprint race at the Sao Paulo Grand Prix.
The Dane was fastest just before George Russell spun his Mercedes into the gravel at Interlagos, bringing out the red flags with eight minutes remaining and the weather deteriorating.
There was no chance of anyone else going faster than Magnussen's time of one minute and 11.674 seconds.
"I don't know what to say," he said.
"The team put me out on the track on the exact right moment. We were the first out in the pitlane and did a pretty decent lap and we are on pole. It's incredible."
Red Bull's double world champion Max Verstappen will join Magnussen on the front row for Saturday's sprint race at Interlagos while Russell still qualified third.
"You're kidding," a shocked Magnussen said over the team radio when told he was fastest when the red flags were waved. "I've never, ever felt like this in my life. Don't celebrate yet, guys."
He did not have to wait long, with the team garage erupting in joy at the end of the session and Magnussen emerging from his parked car to hug jubilant principal Guenther Steiner and his pit crew.
Under the sprint format, the driver who sets the fastest lap in Friday qualifying claims pole position for the record books even if he does not start Sunday's grand prix from the front of the grid.
That final grid is decided by Saturday's 100km sprint race, which also awards points to the top eight.
Saturday will be the third sprint of the season, with Verstappen winning the two previous ones at Imola and Austria.
The hour-long session started in damp conditions after a light drizzle with drivers heading out on intermediate tyres and then switching to slicks as the track dried and threatened rain held off.
McLaren's Lando Norris, who qualified fourth, was fastest in that frantic first phase - 0.297 quicker than Mercedes' Lewis Hamilton who had gone from the depths of the danger zone to top with his final flying effort.
Seven-times world champion Hamilton will start the sprint in eighth place.
Williams' Nicholas Latifi, Alfa Romeo's Valtteri Bottas and Guanyu Zhou, AlphaTauri's Yuki Tsunoda and Haas's Mick Schumacher all failed to make it through to phase two.
Australian Daniel Ricciardo was eliminated in the second session of qualifying.
The sky became a darker grey and the rain returned during the second phase, with Verstappen top of the timesheets ahead of Sainz and Leclerc.
Leclerc started the final phase as the only driver on intermediates - a puzzling gamble on immediate rain that failed and meant he had to then pit for softs before he could set a time.
The Monegasque will start 10th on Saturday.
1. Kevin Magnussen, Denmark, 1 minute, 11.674 seconds.
2. Max Verstappen, Netherlands, 1:11.877.
3. George Russell, Great Britain, 1:12.059.
4. Lando Norris, Great Britain, 1:12.263.
5. Carlos Sainz Jr, Spain, 1:12.357.
6. Esteban Ocon, France, 1:12.425.
7. Fernando Alonso, Spain, 1:12.504.
8. Lewis Hamilton, Great Britain, 1:12.611.
9. Sergio Perez, Mexico, 1:15.601.
Eliminated after second session:
10. Esteban Ocon, France, 1:11.587.
11. Alexander Albon, Thailand, 1:11.631.
12. Pierre Gasly, France, 1:11.675.
13. Sebastian Vettel, Germany, 1:11.678.
14. Daniel Ricciardo, Australia, 1:12.140.
15. Lance Stroll, Canada, 1:12.210.
Eliminated after first session
16. Nicholas Latifi, Canada, 1:15.095.
17. Guanyu Zhou, China, 1:15.197.
18. Valtteri Bottas, Finland, 1:15.486.
19. Yuki Tsunoda, Japan, 1:16.264.
20. Mick Schumacher, Germany, 1:16.361.