LONDON — First, Rafael Nadal erased a two-set deficit. Then, he erased four match points. Nadal could not, however, erase the fifth.

After digging himself out of difficult situations over and over during the course of a riveting encounter that lasted more than 4½ hours, Nadal suddenly faltered, getting broken in the last game and losing to 16th-seeded Gilles Muller of Luxembourg 3-6, 4-6, 6-3, 6-4, 15-13 in the fourth round of Wimbledon on Monday.

The surprising defeat extended Nadal’s drought without a quarterfinal berth at the All England Club to six years.

He has won two of his 15 Grand Slam championships at Wimbledon, and played in the final three other times, most recently in 2011. But since then, Nadal’s exits at the All England Club have come in the first round (2013), second round (2012, 2015) and fourth round (2014, 2017).

All of those losses, except Monday’s, came against men ranked 100th or worse. The 34-year-old Muller is not exactly a giant-killer: He had lost 22 consecutive matches against foes ranked in the top five. And he’d only reached a Grand Slam quarterfinal once before, at the 2008 U.S. Open.

But Muller managed to pull this one out, unfazed but allowing opportunities to pass him by.

Nadal served from behind throughout the final set and was twice a point from losing in its 10th game. He again was twice a point from losing in the 20th. Only when Muller got yet another chance to end it did he, when Nadal got broken by pushing a forehand long.

Nadal entered the fourth-round match having won 28 consecutive completed sets in Grand Slam play, equaling his personal best and a total exceeded only twice in the Open era. He arrived at the All England Club coming off his record 10th French Open championship, and 15th major trophy overall, and seemed primed to be a factor once again at the grass-court tournament.

Muller, though, presented problems. He already owned one victory over Nadal at Wimbledon, back in the second round in 2005.

That was before Nadal figured out how to bring his talents to bear on grass. From 2006-11, Nadal reached the final in five consecutive appearances at Wimbledon (he missed it in 2009 because of bad knees), winning titles in 2008 and 2010.

Muller’s next opponent will be 2014 U.S. Open champion Marin Cilic.

Other men’s quarterfinals matchups are defending champion Andy Murray vs. 24th-seeded Sam Querrey of the U.S., seven-time champion Roger Federer vs. 2016 runner-up Milos Raonic and 2010 runner-up Tomas Berdych against Novak Djokovic or Adrian Mannarino. The Djokovic-Mannarino fourth-rounder was postponed until Tuesday; it had been scheduled to be played on No. 1 Court after Nadal-Muller concluded.