Lorenzo improved on his 2016 record on his first flying lap, beating Marquez's previous top time - already the best of the weekend - by two-and-a-half tenths.
The duo stayed first and second until the mid-session lull and both returned to the track relatively early, beginning a fast lap with six minutes still on the clock.
San Marino Grand Prix
Fenati handed two-race ban for 'irresponsible' brake grab
However Lorenzo did not improve and then pitted, as Marquez's wild effort ended with a fast crash at the Turn 15 left-hander.
Marquez then sprinted back to the garage and mounted his second bike with four minutes left of the session to run, but the Honda rider could not improve his previous time.
Lorenzo on the other hand managed to lower his benchmark by a further tenth as the chequered flag fell, topping the session with a best time of 1m31.629s.
Jack Miller moved into second just as Marquez crashed and the Pramac Ducati rider kept the position to secure his second front-row start of the season.
The front row will be completed by Yamaha's Maverick Vinales, who narrowly edged out Lorenzo's Ducati team-mate Andrea Dovizioso on his last lap.
Marquez ended up fifth, ahead of Cal Crutchlow (LCR Honda), who also had a crash, and the second factory Yamaha of local favourite Valentino Rossi.
Danilo Petrucci (Pramac) was the fourth Ducati in the top eight, with Johann Zarco (Tech 3 Yamaha) and Alex Rins (Suzuki) taking ninth and 10th, ahead of the two riders to advance from Q1, Dani Pedrosa and Franco Morbidelli.
Morbidelli chose to do one run to save tyres and then failed to set a representative lap time as he crashed at Turn 4.
Honda riders Pedrosa and Morbidelli made it through Q1 at the expense of Suzuki's Andrea Iannone, who missed out on Q2 for the first time this season.
Iannone will start Sunday's race 13th, ahead of Ducati wildcard Michele Pirro, whose own chances of making it to Q2 were over after a late crash at Turn 10.
World Superbike-bound Alvaro Bautista (Nieto Ducati) will line up 15th on the grid ahead of Aleix Espargaro (Aprilia) and Bradley Smith (KTM).
Honda wildcard Stefan Bradl was 18th as Pol Espargaro, returning from injury, qualified 20th on the second KTM.
Xavier Simeon, riding the injured Tito Rabat's Ducati GP17, had a crash at Turn 16 and will start 22nd, two places ahead of fellow faller Karel Abraham.
MotoGP debutant Christophe Ponsson, riding Simeon's Avintia Ducati GP16, rounded out the order, his 1m37.180s nearly five seconds off the pace.
San Marino Grand Prix
Dovizioso takes Misano win, Lorenzo crashes
Grand Prix Valencia
'An inspiration for me' - Federer leads Rossi tributes after final race