Marquez outpaced future Honda team-mate Jorge Lorenzo by 0.138 seconds in a late-session dash.
Suzuki's Andrea Iannone had set the early pace with a 1m48.381s, and remained out front for almost the whole 45-minute duration of FP2, as leading riders focused on getting mileage with the sturdier hard rear tyre.
But when Ducati's Andrea Dovizioso emerged on the soft front and soft rear in the closing minutes, the Italian beat his former team-mate's benchmark by more than half a second at the first attempt, setting a new best lap of the weekend - a 1m47.835s.
LCR Honda's Cal Crutchlow had been even quicker after three sectors, but following Dovizioso across the line came up 0.027s short.
However, fellow Honda rider Marquez then fired in a 1m47.382s to end the day quickest. As the chequered flag flew, Lorenzo vaulted up from 11th to second, demoting his works Ducati team-mate Dovizioso another spot.
Crutchlow settled for fourth, while Iannone improved at the chequered flag to snatch fifth place back from Pramac Ducati's Danilo Petrucci.
Honda's Dani Pedrosa and Nieto Ducati rider Alvaro Bautista followed in seventh and eighth respectively, although both were already more than a second off Marquez's pace.
The factory Yamaha team underwhelmed, but both Valentino Rossi and Maverick Vinales sneaked into the combined classification top 10, which will determine automatic progression to the Q2 pole position shootout session after FP3 on Saturday.
Rossi was ninth, while Vinales stole 10th place at the death by a tenth from Marc VDS Honda rider Franco Morbidelli.
Two frequent Q2 participants - Suzuki factory rider Alex Rins and Tech3 Yamaha's Johann Zarco - struggled in 16th and 17th respectively.
Avintia debutant Jordi Torres improved on his FP1 showing, lapping 3.7s off Marquez's pace.