Slovenia's Primoz Roglic is set to win the Vuelta a Espana for the second year in succession, and bury his Tour de France heartbreak, after finishing the final competitive stage on top of the overall standings on Saturday.
Roglic came under intense pressure from Ineos leader Richard Carapaz on the final climb with the Ecuadorian set for the runner-up position, 24sec adrift after the 17th stage won by Frenchman David Gaudu.
"I wasn't always in control," a smiling Roglic admitted after a stage with hills galore, cobbles, narrow village lanes and misty clouds on the summits.
"I had just enough left," he said. "I'm super happy, and it's a really nice way to finish the season."
Jumbo-Visma all-rounder Roglic took the Vuelta overall lead on stage one and was in a struggle with Carapaz for the leader's red jersey all the way with the Ecuadorian taking the lead for five stages.
Carapaz beat Roglic to the 2019 Giro d'Italia title before joining Ineos.
"I really wanted to win this Vuelta but I'm satisfied with the second place because we produced our best performance," Carapaz said.
Roglic still needs to complete Sunday's 139km parade to Madrid where the 2020 edition will almost certainly end in a mass sprint.
The victory comes after Roglic's late meltdown at the Tour de France, where he lost the lead on the penultimate day with his compatriot Tadej Pogacar winning the race.
In the closing kilometres of Saturday's stage, there was a feeling that Roglic was in danger of suffering a similar fate.
With three kilometres to go, Carapaz attacked, peeling away from Roglic and Hugh Carthy and wheeling away up the steep slopes of the final climb that ended at 1965m altitude on a cold misty mountaintop finish.
British rider Carthy of the American team Education First is in third position, 47 seconds off the leading pace.
One of the early pace setters, Dan Martin of Ireland, came fourth, the best result his team Israel Start Up Nation have yet scored as they await the arrival of Chris Froome in January.
"It's been one hell of a ride and to get the best Grand Tour result of my career and a stage victory, we could not have imagined such results three weeks ago," said Martin, who won a stage and achieved a personal best overall finish on a three-week race.
"It's a milestone for the team as we build into what is an incredibly exciting year next year where our ambitions as a team will be even greater," he said of the team that also won stages on the Tour and the Giro in its first season at the top level.
The stage itself was won by Gaudu of Groupama-FDJ, the 24-year-old's second stage win of this Vuelta, and he celebrated by throwing back his head and letting out a victory cry with his arms spread wide.
"I enjoyed the cold and the rain, that's my kind of weather," he said after his stage win that saw him move into ninth overall.
The Vuelta has been cut to 18 stages in 2020 and delayed from its usual August slot.