Angel Madrazo completed a spectacular comeback to triumph in the Vuelta a Espana's first summit finish, while Miguel Angel Lopez regained the red jersey with a powerful attack.
Madrazo almost came off his bike when he was clipped by the bumper of a support car with 24 kilometres of the 170.7km ride to go and was dropped by breakaway companions Jose Herrada (Team Cofidis) and Burgos BH team-mate Jetse Bol three times on the gruelling climb to the Javalambre Astrophysical Observatory.
The polka dot jersey holder made an inspired charge in the final kilometre and completed a one-two with Bol, who edged away from Herrada at the last.
Lopez crossed the line in fourth to take the red jersey back from Nicolas Roche, the Irishman slipping to fifth in the general classification after failing to follow the Astana rider.
Primoz Roglic moved ahead of Nairo Quintana and into second in the GC, with Alejandro Valverde rising to fourth.
However, stage five belonged to Madrazo, who was in tears after crossing the line on stage five.
Having claimed his first stage win at a Grand Tour, an emotional Madrazo explained that he contravened team orders after seeing weakness in Bol and Herrada.
"I didn't expect to win. I want to dedicate this victory to my wife. It's a dream come true," said Madrazo.
"We have suffered throughout the season, the team deserved it. I could not follow the rhythm of Herrada, I had to go slower not to wear myself out.
"I wanted to help Jetse, who has waited for me. In the sprint I am fast. The team told me to save [myself] for tomorrow, but when I caught them I saw that they were weak and I attacked."
1. Angel Madrazo (Burgos BH) 4:58:31
2. Jetse Bol (Burgos BH) +00:10
3. Jose Herrada (Cofidis) +00:22
4. Miguel Angel Lopez (Astana) +00:47
5. Alejandro Valverde (Movistar) +00:59
1. Miguel Angel Lopez (Astana) 18:55:21
2. Primoz Roglic (Jumbo-Visma) +00:14
3. Nairo Quintana (Movistar Team) +00:23
1. Sam Bennett (Bora-Hansgrohe) 45
2. Fabio Jakobsen (Deceuninck-Quick Step) 34
3. Nairo Quintana (Movistar) 33
King of the Mountains
1. Angel Madrazo (Burgos BH) 33
2. Jetse Bol (Burgos BH) 11
3. Alejandro Valverde (Movistar Team) 6
Stage six is a hilly, in-land 198.9km route from Mora de Rubielos to Ares del Maestrat, finishing on a 5km climb with an average six per cent slope.