Frenchman Johann Zarco will start Sunday's Portuguese MotoGP in pole position on his Ducati Pramac after topping a crash-laden qualifying ahead of Spanish rider Joan Mir.
Aleix Espargaro was third quickest in Portimao on Saturday, while reigning world champion Fabio Quartararo will begin the fifth race of the year in fifth place.
Championship leader Enea Bastianini failed to make it through to Q2 after falling and finished 18th.
Zarco's pole was the seventh of his career, but the twice-former Moto2 champion has never won a race in the elite category.
"I didn't expect such a good lap," said Zarco, who made the most of a drying track as the sun came out following rain-soaked practice sessions.
"It was tricky in the afternoon with the wet patches and we were asking ourselves which tyres to use during the last practice session.
"We were finally able to use the dry tyres for the qualifying and that worked really well."
Several of the favourites struggled to master the slick surface, with Francesco Bagnaia appearing to injure his shoulder after a heavy tumble in Q1.
The Italian was taken to the circuit's medical centre where scans showed no fracture, but he was then transported to a nearby hospital for further tests.
"I hate to say that I was scared. You always have to say you have respect but today, no I'm sorry, I was scared, because the wet patches were very slippery," said Aleix Espargaro.
"When you're sitting in the garage and you see in Q1 there are many crashes, all of them huge, you have to be focused and very sure, but you cannot.
"For me this is like a victory, I hate these conditions."
- Unlucky Marquez -
Six-time world champion Marc Marquez was in contention for pole but his lap was cancelled as Honda team-mate and compatriot Pol Espargaro crashed on the final corner.
Marquez qualified in ninth just ahead of Pol Espargaro, having walked away from another crash in practice as he lost control in a corner and flew over the handlebars.
His head hit the tarmac after he landed but he got straight up, shaking his head.
He crashed in practice for the Indonesian Grand Prix and missed that race and the next one in Argentina with a recurrence of his double vision.
The Spaniard had thrived in the rain on Friday, setting the fastest time.
Quartararo said he was "very happy" to be on the second row but rued not being able to record a last lap after yellow flags came out in the wake of another spill.
"The top five really have the potential to be on the podium tomorrow," said Quartararo, also suggesting it would be foolish to write off Marquez's chances.
Local rider Miguel Oliveira was unable to replicate his fast practice times and had to settle for 11th in qualifying.
"I don't think the starting grid is a good indication of the race result tomorrow... because of me," he said.
Spain's Aron Canet will line up on his Kalex at the front of the grid for Sunday's Moto2 race, while Turkey's Deniz Oncu of KTM took pole in Moto3 qualifying.