Ferrari's Charles Leclerc grabbed pole from Red Bull's Max Verstappen at the end of a dramatic qualifying session at the Australian Grand Prix.
The final session was interrupted by a red flag following a crash for Fernando Alonso's Alpine after an apparent hydraulic failure.
Leclerc had just set the fastest time when Alonso went off, but was beaten by Verstappen when the session resumed.
But Leclerc pulled out a fine lap at the end to take pole by 0.286 seconds.
Red Bull's Sergio Perez took third, with McLaren's Lando Norris fourth ahead of the Mercedes cars of Lewis Hamilton and George Russell.
Ferrari's Carlos Sainz was only ninth fastest after a difficult session.
The Spaniard's first flying lap did not register because the red flag was thrown for Alonso's crash just as Sainz approached the line.
And then he could not deliver a representative lap on his final run, ending up 1.5secs slower than his team-mate.
But possibly the biggest loser was Alonso, who was 0.2secs up on Leclerc's first lap time after two sectors of his flying lap before his incident.
Alonso ran wide of the apex entering the corner, got on to the kerb and slid into the gravel and then the wall.
"We lost the hydraulics on the car, so we lost the gear change and power steering and everything," said Alonso, who last year returned to F1 after a two-year break in the hope of a competitive car in 2022 and has not competed at the front since 2013.
"I think we could fight for pole position today. Been waiting many years for that possibility and it is amazing we have been so unlucky in these first three races. I was doing one of the best weekends in years and it is very frustrating now."
What did the drivers say?
The stage appears set for another showdown between Leclerc and Verstappen, the winners of the two races so far after close battles at each.
Perez's presence at the front gives Red Bull a tactical advantage over Ferrari, but the Mexican is under investigation for allegedly not slowing sufficiently for yellow caution flags and may face a penalty.
Leclerc said: "It felt good, even more because it is a track I have always struggled at in the past. It was a bit of a messy free practice for me, not everything together. But in Q3 I managed to put everything together and very happy to be starting on pole."
Verstappen said: "I didn't feel good in the car the whole weekend so far. There wasn't one lap where I felt confident. Second is good but it's not great when you can't go to the limit."
Sainz was left fuming after a spiralling series of problems following the Alonso red flag.
A delay starting the car in the garage meant he did not have enough time for his usual tyre preparation, so his tyres were "freezing" when he went for a time, leaving him with no grip.
He felt a shot at pole had been denied him.
A small McLaren revival
The McLarens have hit form in Melbourne after a poor start to the seasonNorris's fourth place was a highly impressive showing by McLaren after a difficult start to the season.
The team had not managed to get either car into the final part of qualifying at either of the preceding races but in Melbourne both drivers made it through, and Norris was able to beat the Mercedes cars to take up position as best of the rest behind the top two teams.
It has been another difficult weekend for Mercedes, but fifth and sixth is probably the best they would have expected in qualifying, albeit they would have expected the four cars from Ferrari and Red Bull to be ahead rather than a McLaren.
The silver cars are still suffering badly from aerodynamic bouncing on the straights, which is affecting the drivers' confidence into fast corners, especially the 150mph Turns Nine and 10.
Hamilton was 0.957secs off Leclerc's pole position time and 0.108 ahead of Russell, who has been close to him all weekend.
The second McLaren of Daniel Ricciardo was seventh, from Alpine's Esteban Ocon, Sainz and Alonso.
Aston Martin's Melbourne travails
Aston Martin have had a trying weekend. Both cars crashed in final practice earlier on Saturday, giving the mechanics a tough job to get the cars ready for qualifying.
Sebastian Vettel's mechanics were about to run out of time, only for his team-mate Lance Stroll to collide with Williams driver Nicholas Latifi in a bizarre incident when both were on warm-up laps and bring out the red flag.
Latifi had slowed to let what he thought was a faster car through, but when Stroll passed him, also going at reduced speed, he attempted to re-take his fellow Canadian between Turns Five and Six, only for the Aston Martin to move across and clip his left-rear tyre, sending the Williams into the wall and damaging Stroll's suspension.
At a post-qualifying hearing, race stewards adjudged Stroll to be "predominantly to blame" for the crash and issued a three-place grid penalty - a largely academic punishment for a driver who was already starting 20th and last.
That gave Vettel the chance to get out but the four-time champion could manage only 18th fastest time on his one lap - more or less his only flying lap of the entire weekend after an engine failure hampered his Friday running and then his crash on his first flying lap on Saturday.
Latifi's badly damaged Williams is taken away following his bizarre collision with fellow Canadian Stroll