Nadal becomes just the fourth man to achieve 1,000 singles victories in the Open Era, behind Jimmy Connors (1,274), Roger Federer (1,242) and Ivan Lendl (1,068).
Nadal, who was handed a bye in the first round, got off to a terrible start, losing his opening service game and never really coming to terms with Lopez’s blistering serve.
Lopez, 39, won a scarcely believable 93% of his first serve points and also sent down eight aces as he wrapped up the opening set in style.
With both players evenly matched, the second set stayed on serve before Nadal edged a tiebreak to send the contest to a decider.
Nadal broke Lopez in his first service game of the third set and then showed his usual levels of laser-like focus to close out the match.
Next up for the 20-times Grand Slam champion is a meeting with Australia’s Jordan Thompson in the last 16.
Elsewhere, fourth seed Alexander Zverev beat Serbia’s Miomir Kecmanovic 6-2 6-2 to set up a meeting with France’s Adrian Mannarino for a place in the quarter-finals.