The win is Sosa's third consecutive victory in this stage of the Vuelta.
The 22-year-old Colombian attacked in the last kilometre to claim his hat-trick.
World Championships
Evenepoel hits back at Merckx criticism
17 HOURS AGO
"I knew the climb very well and I knew I had to wait until the final ramp. I was at the limit, and everything turned out well," Sosa said.
"We're all happy we're back to racing with this situation."
For Deceuninck-QuickStep's Evenepoel, the stage was a chance to cement his lead at the top having been ahead since stage three.
While Bahrain McLaren's Mikel Landa attempted to reel him in during the four km ascent at the stae end, the Belgian athlete held his nerve, and the lead, just behind Landa.
Landa's charge earned him second place in the general classification but it was not enough to leaprog Evenepoel.
"This is a perfect day," Evenepoel told reporters. "The team worked perfectly, kept me in position and it was my job to finish it. I'm glad it worked out. This was my third stage race this season and I'm winning for the third time.
"It was harder than two days ago when I won the stage, but luckily I had a good team around me and got the job done."

General Classification

1 Remco Evenepoel (Bel) Deceuninck-Quickstep 19:14:42
2 Mikel Landa Meana (Spa) Bahrain McLaren 0:00:30
3 João Almeida (Por) Deceuninck-Quickstep 0:01:12
4 Esteban Chaves (Col) Mitchelton-Scott 0:01:26
5 George Bennett (NZl) Team Jumbo-Visma 0:01:40
6 Richard Carapaz (Ecu) Team Ineos 0:01:58
7 Ben Hermans (Bel) Israel Start-Up Nation 0:02:25
8 David De la Cruz Melgarejo (Spa) UAE Team Emirates 0:02:34
9 Fabio Aru (Ita) UAE Team Emirates 0:02:36

Tour de France 2012: Mark Cavendish wins final stage as Bradley Wiggins triumphs

World Championships
Belgian fans can dream of having it all once more - thanks to Van Aert and Evenepoel
19/09/2021 AT 20:19
World Championships
Ganna defends world TT title after thrilling battle with Van Aert
19/09/2021 AT 15:11