Marquez, who had a crash in the FP4 session that preceded qualifying, was sat behind Rossi on his final Q2 lap and looked on course to secure a front row spot.
But after the championship leader overtook Rossi at Curvone, the Yamaha rider closed back up after Marquez ran wide and launched it down the inside of the Honda man at the hairpin-like Turn 14, with both riders' laps compromised as Rossi ran wide.
Marquez was thus left fifth on the grid, five tenths off Vinales and two places up on Rossi.
Practice pace-setter Fabio Quartararo had taken the early lead in Q2 with a 1m32.686s, and bettered that with a 1m32.571s next time by as he and Franco Morbidelli made it a Petronas Yamaha 1-2 after the opening runs.
Morbidelli then looked set to challenge his teammate's benchmark, only to have his fastest lap thwarted by a slide that very nearly led to a highside.
But Quartararo likewise struggled to improve, and while he backed out of his final attempt, Espargaro - who had tucked in behind the rookie - eclipsed him with 1m32.560s.
This meant the Spaniard briefly held provisional pole for KTM, only for Vinales to find another three tenths for a 1m32.265s and grab the top spot.
Quartararo and Morbidelli completed the top four ahead of Marquez and Ducati's Andrea Dovizioso, who had been outside the top 10 for much of the session.
Espargaro's KTM teammate Johann Zarco will line up between Rossi and Suzuki's Alex Rins on the third row after having progressed from Q1.
Another rider to advance from the opening segment, Rins' teammate Joan Mir, will start 10th ahead of LCR Honda's Takaaki Nakagami - whose squadmate Cal Crutchlow had to settle for 14th - and Ducati wildcard Michele Pirro.
Pramac Ducati rider Francesco Bagnaia came up 0.003s short of advancing from Q1 at Mir's expense, and will line up 13th on the grid.
Bagnaia did see off the likes of Pramac teammate Jack Miller, who held a provisional Q2 spot after the first runs but dropped down to 16th, and works Ducati rider Danilo Petrucci, who recorded his worst grid position of the season in 17th.
Aleix Espargaro was ahead of both in 15th for Aprilia, but his teammate Andrea Iannone was absent from the session entirely, after an FP4 crash - his third of the weekend - forced him to go to the medical centre with pain in his left shoulder.
Honda's Jorge Lorenzo, still recovering from injury, will line up 18th on the grid, having lapped six tenths off Q1 pace-setter Zarco.
|View full results|
|View full results|