Five-times MotoGP world champion Marquez, who set a best lap of two minutes 03.787 seconds, is unbeaten at the track and has won there for the past six seasons.
Italian great Rossi was 0.237 slower than Marquez as he qualified on the front row for the first time since Malaysia last October.
Marquez's team mate and compatriot Jorge Lorenzo lost time when his bike had a chain problem and he had to lean it against the pitwall before jogging back to the garage for a spare bike. He qualified 11th.
Ducati's Dovizioso, four points behind championship leader Marquez after two races, failed to make it through the first qualifying session.
The day's final practice sessions were cancelled due to the risk of lightning strikes but the bad weather then eased off in the afternoon, with qualifying run under blue skies.
(Writing by Alan Baldwin in London, editing by Pritha Sarkar)
