Toseland is a two-time World Superbikes champion
MotoGP debutant James Toseland earned the right to start from second place on the grid for the Qatar Grand Prix.
The Briton was on course for pole under the lights at Losail until fellow Yamaha newcomer Jorge Lorenzo snatched the front spot in the dying seconds.
The 20-year-old Spaniard set a MotoGP lap record of one minute 53.927 seconds to finish 0.255sec ahead of Toseland.
"I haven't done bad for a Superbike rider," said the Briton. "An amazing session and I nearly took pole."
He added: "It's been a great season so far and the team has been fantastic. I've got a good race set-up and can't wait to make that debut."
Toseland's Tech 3 Yamaha team-mate Colin Edwards will start in third, with world champion Casey Stoner in fourth.
Nicky Hayden, the 2006 champion, starts in sixth spot, one place ahead of four-time MotoGP Valentino Rossi.
The opening race of the season will be the first to take place under floodlights.
The lights are so powerful that some riders have said it is almost like riding in daylight anyway.
But the track temperature could prove to be a more significant factor, because of the significant late-night drop in heat in the desert.
Qualifying results for Sunday's Qatar Grand Prix:
1 J Lorenzo (Sp) Yamaha 1min 53.927secs
2 J Toseland (GB) Yamaha 1:54.182
3 C Edwards (USA) Yamaha 1:54.499
4 C Stoner (Aus) Ducati 1:54.733
5 R de Puniet (Fr) Honda 1:54.818
6 N Hayden (USA) Honda 1:54.880
7 V Rossi (It) Yamaha 1:55.133
8 D Pedrosa (Sp) Honda 1:55.170
9 A Dovizioso (It) Honda 1:55.185
10 J Hopkins (USA) Kawasaki 1:55.263