World championship leader Lewis Hamilton will start from pole position for Sunday's Malaysian Grand Prix with title rival Sebastian Vettel at the back of the grid.
Hamilton had been off the pace all weekend in practice but his Mercedes team turned it around in qualifying Saturday to head Ferrari's Kimi Raikkonen and the Red Bull of Max Verstappen.
But Vettel's world championship hopes suffered a huge blow when his Ferrari failed to set a time in the first qualifying session, meaning he will start last.
Vettel, 28 points behind Hamilton in the title race, lost drive on his first flying lap.
"It feels like I have no turbo," he said over team radio.
READ: Sepang circuit given all-clear after freak crash
Hamilton was clearly surprised to be on pole after a torrid weekend where he had failed to be quicker than fifth in any practice session.
"We had no idea what was going to happen today," said Hamilton.
"I'm sorry for what happened to Sebastian but somehow we managed to turn it around and it is a real surprise to be up here with these guys.
"I'm very grateful to the team. The car felt good."
With mechanics unable to fix Vettel's Ferrari before the end of Q1 the German will start from the back of the grid unless there are penalties for other drivers.
READ: This is the last Malaysian GP
Vettel's engine had been changed before qualifying after a similar gremlin in final practice Saturday only for the new unit to fail.
"Who knows what will happen tomorrow," Vettel told AFP. "The race is tomorrow not today. We have a very quick car and we saved some tyres.
"If it happened tomorrow it would be more of a problem. Anything can happen — you saw that in Singapore two weeks ago how everything can change."
In Singapore, Vettel had started from pole only to crash on a rain-soaked first lap as Lewis Hamilton won from fifth on the grid to extend his championship lead.