Starting the day in sixth, seven minutes, 42 seconds behind race leader Primoz Roglic (Jumbo-Visma), Quintana finished ten seconds behind Gilbert to leapfrog Movistar team-mate Alejandro Valverde into second place after gaining five minutes on the red jersey.
The Colombian now sits two minutes 24 seconds back, with two mountain stages still to come as the race nears its conclusion.
Valverde is third, 24 seconds behind Quintana, while fourth-placed Tadej Pogacar (UAE Team Emirates) looks to be out of contention for a podium spot at three minutes 42 seconds.
“We knew how to move, and hopefully I’ll get better physically,” Quintana said after team-mate Nelson Oliveira conceded his breakaway effort had not been planned for by Movistar.
“We were able to profit on a day when anything could’ve happened. I’m feeling a bit better having been suffering with a cold, but we’ll see how I do in the mountains tomorrow.”
The 219.6km flat course - the longest in this year’s race - from Aranda del Duero to Guadalajara was marked by strong crosswinds, which led to a frenetic pace of racing; a remarkable 50.6kph was the average speed throughout.
The wind saw the sizeable breakaway gain a huge advantage over the main peloton, including Valverde and Roglic, which they were unable to claw back, finishing five and a half minutes down on stage winner Gilbert (Deceuninck-Quick Step).
It had looked as though sprinter Sam Bennett was going to claim a third stage of this year’s race, however, Gilbert got away from the BORA-hansgrohe sprinter inside the final 100 meters to seal a second stage victory of the race for himself.
Stage 18 sees the riders tackle four punishing category one climbs over 177.5km between Colmenar Viejo and Becerril de la Sierra in the Madrid region.
More to come.