Valentino Rossi will start on the front row of the Aragon Grand Prix just three weeks on from sustaining a double leg break, with Movistar Yamaha team-mate Maverick Vinales on pole.
The seven-time champion in MotoGP's premier class sustained the injury during a test ride but made a remarkable return to competitive action by qualifying third at Motorland on Saturday.
Rossi will start beside Jorge Lorenzo, the Ducati rider having to come through Q1 after a disappointing showing in FP3, and Vinales.
"I think we did a great job after the injury. I have to thank all the guys that helped me ... the doctor who did the surgery," said Rossi.
"After, I worked very hard. The leg is getting better every day. I feel comfortable on the bike. I can ride with a bit of pain but I can also concentrate on the laps.
"It's very important to start from the front row. We have to understand whether I'm able to push to the end [of the race], but I'm happy."
-- MotoGP(TM) (@MotoGP) September 23, 2017
Title-chaser Vinales set a time of one minute and 47.635 seconds to pip his fellow Spaniard Lorenzo, piling the pressure on joint championship leaders Marc Marquez and Andrea Dovizioso.
Marquez will start in fifth spot after the defending champion was on a projected pole lap when he slipped out and crashed at turn 12, failing to set another time despite getting back on his bike and riding it into the pits.
Dovizioso, meanwhile, was over half a second off the pace and will start from the third row, setting up an exciting battle on Sunday.
1. Maverick Vinales (Movistar Yamaha) 1:47.635
2. Jorge Lorenzo (Ducati) +0.100s
3. Valentino Rossi (Movistar Yamaha) +0.180s
4. Cal Crutchlow (LCR Honda) +0.195s
5. Marc Marquez (Repsol Honda) +0.328s
6. Dani Pedrosa (Repsol Honda) +0.472s
7. Andrea Dovizioso (Ducati) +0.502s
8. Aleix Espargaro (Aprilia Racing) +0.524s
9. Alvaro Bautista (Pull&Bear Aspar) +0.552s
10. Andrea Iannone (Suzuki Ecstar) +0.654s