Dani Pedrosa stunned Yamaha by snatching a last-gasp Honda pole for MotoGP's Italian Grand Prix at Mugello.
Pedrosa was languishing in seventh as the chequered flag fell on Q2, while Lorenzo - who had been quickest in practice - held a dominant provisional pole on a record 1m47.226s.
But Pedrosa found a massive improvement on his last lap and vaulted right up to first, beating Lorenzo by 0.069 seconds as he crossed the line in 1m47.157s.
Andrea Dovizioso's final lap was also a special one, thrusting him forward to third place and a front-row start for Ducati at home.
Neck pain from his Friday practice crash is likely to hamper Dovizioso in the race, though.
There was disappointment for Valentino Rossi. The local hero looked set for a breakthrough qualifying performance as he held third place going into the closing stages, only for the rush of late improvements to shove his Yamaha right down to seventh.
The battered Marc Marquez easily got through from Q1 to Q2 and briefly appeared in a provisional second on the grid. He could not stay there and slipped back to sixth.
Fourth was a great effort for Cal Crutchlow after another qualifying crash.
He fell with eight minutes of Q2 remaining, rushed back for his spare Tech 3 Yamaha and then beat Stefan Bradl and Marquez to fourth place on the grid.
All three factory Ducatis were in the top 10, as Nicky Hayden and Michele Pirro qualified eighth and 10th, split by Alvaro Bautista.
But Pramac Ducati had no bikes in Q2. Ben Spies withdrew following Friday practice as his injuries remained troublesome, and Andrea Iannone could only manage 13th.
Bradley Smith, riding with a hand injury following his practice crash, made it out of Q1 and secured 11th on the grid, ahead of CRT leader Aleix Espargaro.