Lopez, who snatched the lead by winning an uphill finish at La Molina on the fourth stage on Thursday, held off his rivals in the final stage which ended in Barcelona.
The 25-year-old finished ahead of Adam Yates (Mitchelton-Scott), who went on the attack during the finale, by 14 seconds in the overall classification and Egan Bernal (Sky), recent winner of Paris-Nice, by 17 seconds.
"We knew the rivals will try to do something on Montjuic, so we were ready," Lopez said. "I had strong teammates next to me and they did an absolutely incredible job.
"In every moment of the race, even when Adam Yates went away we tried to keep calmness, gaining the terrain back second by second. In the end, it worked out perfectly and I could save my jersey.
"It was a super hard day on the road, but I’ve got the final victory for my team and now I am happy."
It was the Kazakh-funded outfit’s 21st victory of the season after stage wins on Paris-Nice and Tirreno-Adriatico as Lopez added to his Tour of Colombia title.
Davide Formolo won the 143.1km stage, followed by Enric Mas (Deceuninck-Quick Step) and BORA-hansgrohe team-mate Maximilian Schachmann.
"I went into today’s stage with the goal to be in the breakaway and to try from there to win the stage," Formolo said. "On the local laps I thought, now or never, so I just attacked.
"I pulled so hard, but I knew with eight kilometres to go that I could make it.
"The team was great this week, we achieved a lot at this Volta a Catalunya. Now it is time to go home, rest and look forward to the next races.”
Australian Michael Matthews (Sunweb) claimed the points classification off the back of his two stage wins and Thomas de Gendt (Lotto Soudal) was a clear winner of the mountains jersey.
The stage was marred by a crash in a descent that took down Romain Bardet (AG2R), who along with Romain Barguil, the 2017 Tour’s best climber, abandoned the race.
There were no details on Bardet’s injuries while Barguil’s team Arkea-Samsic said he sustained cuts and bruises.