On a largely ceremonial start to the stage, Yates was able to enjoy celebrating with his team-mates and posing for photos on the road to the Spanish capital, knowing he only had to finish in the main group to secure his overall win.
Viviani was able to take his third stage victory of the race, beating Peter Sagan (Bora-Hasgrohe) to the line to deny the world champion a chance of a final victory in the rainbow jersey.
How it happened
The remaining riders of the 2018 Vuelta a España had faced their difficulties for this edition of the race, and faced a pan flat 100km final stage finishing with circuits in Madrid.
The bulk of the first part of the race was dedicated to celebration, with the race leaders and classification winners able to pose for photos and enjoy their successes with their team-mates.
The action only really got going with 59km remaining, when the riders crossed the finish line in Madrid for the first time with 10 circuits to complete.
A definitive breakaway failed to stay away within the first lap, but the second lap saw Diego Rubio (Burgos-BH), Joey Rosskopf (BMC Racing) and Nikita Stalnov (Astana) get away.
They were only able to establish a very narrow gap of 15 seconds over the main bunch and never looked like threatening the stage victory.
With two laps to go they were just holding on to an advantage, but they were eventually caught with 7.2km to go as the sprinters' teams rode hard to keep it all together for a bunch sprint.
The pace was then extremely high through the last lap and heading into the final straight, with race favourite Elia Viviani looking out of position with 2km to go further down the field as Quick-Step drove on the front.
As the riders his the stretch to the finish it was Danny van Poppel (LottoNL-Jumbo) who launched his sprint first, with Peter Sagan coming up on the right hand side of the road. But Viviani was able to emerge, despite losing his lead-out, on the left hand side of the road an powered clear to take the stage victory.
Sagan was able to claim second, while Giacomo Nizzolo (Trek-Segafredo) was able to cross the line in third place.
Simon Yates was then able to roll across the line within the main group, sealing the overall victory with no time changes in the top-10 of GC.
Vuelta a España 2018, stage 21: Alcorcón to Madrid (100.9km)
1 Elia Viviani (Ita) Quick-Step Floors, in 2-21-28
2 Peter Sagan (Svk) Bora-Hansgrohe
3 Giacomo Nizzolo (Ita) Trek-Segafredo
4 Danny van Poppel (Ned) LottoNL-Jumbo
5 Marc Sarreau (Fra) Groupama-FDJ
6 Jon Aberasturi Izaga (Esp) Euskadi Basque Country-Murias
7 Simone Consonni (Ita) UAE Team Emirates
8 Matteo Trentin (Ita) Mitchelton-Scott
9 Tom Van Asbroeck (Bel) EF Education First-Drapac
10 Ryan Gibbons (RSA) Dimension Data, all same time
Final overall classification
1 Simon Yates (GBr) Mitchelton-Scott, in 82-05-58
2 Enric Mas (Esp) Quick-Step Floors, at 1-46
3 Miguel Angel Lopez (Col) Astana, at 2-04
4 Steven Kruijswijk (Ned) LottoNL-Jumbo, at 2:54
5 Alejandro Valverde (Esp) Movistar Team, at 4-28
6 Thibaut Pinot (Fra) Groupama-FDJ, at 5-57
7 Rigoberto Uran (Col) EF Education First-Drapac, at 6-07
8 Nairo Quintana (Col) Movistar Team, at 6-51
9 Ion Izagirre (Esp) Bahrain-Merida, at 11-09
10 Wilco Kelderman (Ned) Team Sunweb, at 11-11
Mountains classification winner: Thomas De Gendt (Bel) Lotto-Soudal
Points classification winner: Alejandro Valverde (Esp) Movistar Team
Combined classification winner: Simon Yates (GBr) Mitchelton-Scott
Best young rider classification winner: Enric Mas (Esp) Quick-Step Floors
Most aggressive rider: Bauke Mollema (Ned) Trek-Segafredo
Thank you for reading 5 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1