Madruzo, part of a three-rider breakaway group, including team-mate Jetse Bol and José Herrada (Cofidis), rode from start to finish to claim the first-ever Vuelta stage victory for Spanish team Burgos-BH.
He also consolidated his grip on the climbers' standings after cresting the Puerto de Alcublas and Alto Fuente de Rubielos first to take the maximum points on offer.
"To win here is one of the biggest achievements as a cyclist and for me it?s become a dream come true," said Madrazo. "We have suffered throughout the season. The team deserved it, this goes for the team."
The 31-year-old's win comes after he struggled to keep pace on the category one Javalambre climb before recovering to take the victory.
Lopez leads the Vuelta general classification by 14 seconds from Jumbo-Visma's Primoz Roglic, sixth on the stage and 23sec from Nairo Quintana (Movistar) who finished fourth.
The 25-year-old Astana rider has pulled clear of a group of contenders for overall victory including world champion Alejandro Valverde (fourth overall) three kilometres from the finish in Javalambre.
"I had a good feeling and I wanted to capitalise on the right moment," Lopez said."We are happy with the work we did today. We are feeling good and everything is going well."
Stage 6 sees the riders take on the hilly 199km between Mora de Rubielos and tAres del Maestrat to an altitude of 1,195 metres above sea level.