Lopez lost the white jersey on Stage 13 to Tadej Pogačar after the UAE-Team Emirates rider won on Los Machucos but his Stage 18 attack also put some GC distance between him and the 20-year-old Slovenian and brought him a bit closer to a podium position currently held by Movistar's Nairo Quintana.
"We started this stage with a goal to do it as hard as possible and to gain time on my rivals. We aimed to do a war on the road, and I think, that we succeeded," Lopez said.
His long-range adventure, which started on the third climb of the day, put Quintana and Pogacar in the hurt box with both riders wilting under the pressure.
"I’ve got in a good position for an attack on the third climb," Lopez said. "I did a good move on Morcuera, but when I was caught back, I just kept on attacking more and more."
Lopez was eventually brought back by the red jersey group of overall leader Primoz Roglic (Jumbo-Visma) after the damage to his two nearest rivals was done.
He continued to push to the finish where he finished fifth on the stage, 17 seconds behind the solo winner Sergio Higuita (EF Education First), and a gain of 59 seconds on Quintana and Pogacar.
"I tried again and again, don’t how, how many times I attacked, but in the end, I went away in a small group, dropping some of my rivals," Lopez said. "I knew, I had to count on myself only, so I pushed and pushed on the first position in the group, trying to get as much time as possible.
"Well, I gained some seconds and now I am fourth in the general classification, taking back the white jersey. However, nothing is done yet in La Vuelta, there are two stages until Sunday."