Charles Leclerc took pole position for the Monaco Grand Prix despite crashing out with just 16 seconds remaining.
The Ferrari driver was leading the time charts when he hit the barriers on the exit of the swimming pool chicane and the session was stopped and did not restart.
Leclerc sustained damage to the front and side of his Ferrari and it remains to be seen if he will start Sunday's race from the front. Leclerc could face a grid penalty if certain parts of his car need to be changed.
Red Bull's Max Verstappen finished second with Valtteri Bottas third for Mercedes. Lewis Hamilton was only seventh on a disappointing day for the championship leader.
Leclerc's quick lap arrived as a timely boost to Ferrari with chairman John Elkann in Monte Carlo to watch the drama unfold.
The Italian team endured their worst campaign in 40 years last season but in the formative rounds of this year have shown encouraging signs of improvement.
However, Leclerc's eighth pole, Ferrari's first since the 2019 Mexican Grand Prix, still arrived as a shock with Verstappen expected to deliver for Red Bull.
Verstappen was on a lap to challenge Leclerc's time but the red flags following the Monegasque's accident ended his charge.
"It is a shame to finish in the wall," said Leclerc. "It doesn't feel the same but I am incredibly happy with my first lap."
Carlos Sainz finished fourth in the other Ferrari ahead of Lando Norris in his McLaren. Hamilton heads Verstappen by 14 points in the standings but was anonymous throughout Saturday's qualifying and faces a tall order in the race with overtaking notoriously difficult.
Mick Schumacher did not take part in qualifying after he crashed out of final practice.
The rookie, and son of seven-time world champion Michael, lost control of his Haas on the exit of Casino Square and slammed into the barriers in the closing minutes.
Schumacher, 22, sustained severe damage to the left-hand side of his car, and Haas were unable to repair his machine in time.
The young German, who will start Sunday's race at the back of the grid, appeared in tears as he was consoled by his team.
George Russell finished 15th for Williams, two places above the double world champion Fernando Alonso.