PARIS — Novak Djokovic’s bid for a 25th Grand Slam briefly hung by a thread on a cold and damp Saturday night at Roland Garros but the Serbian battled back for a 7-5, 6-7(6), 2-6, 6-3, 6-0 win over Lorenzo Musetti in the latest ever French Open finish.

The reigning champion showcased the iron will that has made him one of the game’s greatest players to avoid defeat in a thrilling third-round contest that got underway at 10.37 p.m. local time on Saturday.

Some 4 1/2 hours later at 3.06 a.m. on Sunday morning, the fans who had huddled up under rugs as the 37-year-old orchestrated his superb fightback rose to their feet to lift the roof of the main showcourt.

“He played a fantastic match and came very close to victory,” Mr. Djokovic said on court.

“I was in great difficulties but thanks to your support in the fourth set, I became a different player. It was perhaps the best match I have played here.”

Mr. Djokovic recovered from an early loss of serve and went toe to toe with the Italian in the draining first set before edging in front with a crucial break in the 12th game thanks to some incredible defending.

The world number one lowered his head and gasped for air following that lengthy rally, but was soon in cruise control in the second set with a spectacular drop that gave him a 3-1 lead.

Mr. Musetti, though, broke back and drew level at 4-4 before saving a set point in a high-quality tie break to level the match and the 30th seed took his game up a few notches to break and surge ahead in the third set, before sealing it comfortably as alarm bells began to ring for a fading Mr. Djokovic.

Mr. Djokovic, who ranted about the state of the surface to the umpire, suddenly rediscovered his rhythm to wrap up the fourth before pulling away from his exhausted opponent in the decider. “Who’s going to sleep now?” Mr. Djokovic added. “It’s impossible to sleep, so much adrenaline. If you’re having a party, I’m coming.”

Fourth seed Alexander Zverev also survived a scare in an evening marathon to move into the fourth round with a 3-6, 6-4, 6-2, 4-6, 7-6 (10-3) victory over Dutchman Tallon Griekspoor.

In the women’s draw, second seed Aryna Sabalenka beat best friend Paula Badosa 7-5, 6-1 in a testing clash, while Russian-born Frenchwoman Varvara Gracheva won plenty of new admirers after she kept the flag flying for her adopted country.

After Corentin Moutet had given French supporters a Friday night to savor with victory over Sebastian Ofner, new crowd favorite Ms. Gracheva lit up another soggy day with a 7-5, 6-3 victory over Irina-Camelia Begu.

The last Frenchwoman left in the women’s draw was treated to a rousing rendition of the national anthem “La Marseillaise” and she joined the fans in celebration. “I’ll remember this moment until the end of my life,” said a beaming Ms. Gracheva.

“It means that everyone accepts me, that I’m home here.”

While Gracheva was center of attention in the afternoon, fellow Moscow-born player Elena Rybakina continued to fly under the radar as the fourth seed cruised past Elise Mertens 6-4, 6-2.

Canada’s Felix Auger-Aliassime, the 21st seed, closed out a 6-4, 6-2, 6-1 victory over American Ben Shelton under the Suzanne Lenglen roof, as rain delayed action on the outer courts.

When play resumed, Alex De Minaur completed a 4-6, 6-4, 6-3, 6-3 win over Jan-Lennard Struff to become the first Australian man into the Paris fourth round since Lleyton Hewitt in 2007, and launched a search for a superfan who spurred him on. — Reuters