Four-times world champion Marquez lapped the Buriram circuit in one minute 30.088 seconds on his Honda, pipping Yamaha's veteran Rossi by 0.011 seconds on a scorching hot day.
Ducati's Andrea Dovizioso took the third spot on the front row, with Yamaha-rider Maverick Vinales fourth.
Marquez, on 246 points, holds a commanding 72-point lead in the championship race ahead of second placed Dovizioso with five races left in the series.
Ducati rider Jorge Lorenzo, fourth in the championship, earlier pulled out of the race weekend after injuring his wrist during a heavy fall in Friday's second practice.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
(Reporting by Ian Ransom in Melbourne; Editing by Amlan Chakraborty)
