The Spaniard, who defeated Gasquet's French compatriot Gilles Simon 12 months ago, needed two hours and 13 minutes to edge an epic contest 6-3 6-7 (5-7) 7-5 win at the ATP 250 grass-court tournament in Eastbourne on Saturday.
Lopez has enjoyed a fine season on the grass thus far, having finished runner-up to Grigor Dimitrov at the Aegon Championships at the Queen's Club last weekend.
Gasquet - who was gunning for his 11th Tour title - had won all of the five previous encounters between the pair, but the Frenchman was the back foot early as Lopez broke in just the third game and held for a 3-1 lead.
And the world number 14 lost the first set with a whimper, as he once more surrendered the advantage when serving to stay in the set at 5-3 adrift.
Gasquet showed signs of improvement in the second and broke in the seventh game for a 4-3 lead, only for Lopez to immediately return the favour.
A tie-break ensued and, though he initially let a mini-break slip, Gasquet powered through to level the match.
The third set proved a terse affair, though Gasquet did waste a pair of break points in Lopez's first service game of the decider.
The rest of the set went with serve until finally Lopez made the breakthrough for a 6-5 lead, and duly served out to 15 before falling to the floor in elation.
Lopez now meets Yuichi Sugita in the first round at Wimbledon where he is aiming to go beyond the third round for the first time, while Gasquet opens against James Duckworth.