Jorge Lorenzo will start second, while joint-points leader - with Marquez - Andrea Dovizioso finished down in seventh.
Marquez, who has been on pole at Aragon every year since making his premier class debut in 2013, seemed well set for a fifth consecutive pole at the Spanish track at the halfway stage of Q2, after he became the first rider to break the 1m48-second barrier this weekend.
The reigning champion's benchmark of 1m47.963s put him three tenths up on the pack, led by Q1 pacesetter Jorge Lorenzo, before Vinales slotted between his two countrymen on a 1m48.142s.
But at the start of the final runs, Marquez's pole bid unravelled as the Honda rider suffered a high-speed off at Turn 12 with two minutes left on the clock.
Moments later, Yamaha's Rossi - just 23 days on from breaking his right leg in a motocross crash - jumped to the top of the times on a 1m47.815s.
But any hopes of the Italian taking a shock pole on his MotoGP return were ended by his teammate Vinales, who went 0.180s faster on a 1m47.635s.
Ducati rider Lorenzo then split the Yamahas with a time exactly one tenth slower than Vinales.
Cal Crutchlow ended up best of the Hondas on his satellite LCR machine in fourth, only 0.015s behind Rossi, while Marquez found himself pushed down to fifth, ahead of team-mate Dani Pedrosa.
Dovizioso was subdued on the second factory Ducati, half a second down on Vinales.
Aleix Espargaro (Aprilia), Alvaro Bautista (Aspar Ducati) and Andrea Iannone (Suzuki) completed the top 10, while Tech 3 Yamaha's Johann Zarco and KTM wildcard Mika Kallio completed the Q2 field.
Kallio had embarrassed both of KTM's regular riders by qualifying directly into Q2 with the fifth-fastest time in practice, but crashed late on and was demoted to 12th.