Just before 6pm on day 10 at Roland Garros, the light was fading as fast as the aura of two of the greatest players to grace the game.

The world No1, Novak Djokovic, and the world No3, Roger Federer, found themselves in roughly similar holes at around the same time on courts no more than a couple of hundred yards apart, but with contrasting challenges, as they fought desperately to stay in the French Open, hoping to meet each other in the semi-finals on Friday.

Three hours later, give or take a few minutes and a Shakespearean chunk of drama, they had accomplished it.

In the early stages of their twin odyssey, it looked grim for both of them. On Court Philippe Chatrier, in front of the same crowd who had simultaneously abused yet inspired Andy Murray the night before, Djokovic and Jo-Wilfried Tsonga were a set apiece and their quarter-final was going with serve midway through the third. The Frenchman was marginally in better shape. Djokovic looked worried, and with good reason.

On Court Suzanne Lenglen, Federer was two sets down to Juan Martín del Potro after losing a scintillating tie-break. Two incidents describe the tension during that fraught period. At 4-4 in the second, Federer netted a backhand and belted the loose ball up the other end, coming dangerously close to hitting a ball kid. Had the ball struck, he would have been disqualified from the tournament – as a then little-known Tim Henman was at Wimbledon in 1995, when he thrashed a spare ball during a doubles match, striking ball girl Caroline Hall on the head.

Shortly afterwards, during the tie-break, Federer screamed "Shut up" at the crowd after netting a backhand at the end of a rally in which his previous shot had gone perilously close to the baseline. This was a rare sighting of the racket-bashing brat of his teenage years. The cold facade had dropped under pressure.

"Obviously I was emotional," he said, "and I was upset. I knew it could be crucial to the match. Thank God it wasn't but in the moment itself you don't know."

Within half an hour or so, Djokovic was in danger of drowning in the drizzle that bathed Chatrier, as Tsonga conjured a piece of running, cross-court magic that left the Serb speechless and rooted to the spot 10 feet from the net in centre court. About that time, Federer, who has come from two sets down six times in his career, was easing into his fightback, as he took the third set from a distracted Del Potro, then broke him at the start of the fourth.

The greater emotional content filled Chatrier where the crowd, who had invested so much misguided faith in Richard Gasquet against Murray, now gave Tsonga, an equally unreliable yet enchanting talent, their full-throated approval.

Federer continued his quiet assassination on Lenglen, as Del Potro floundered, his heavily strapped leg restricting his sideways and forward movement. The Swiss was ruthless in cutting him down over the final stretch. He bagelled him then finished him off.

Federer said he did not notice Del Potro struggling physically. The Argentinian revealed he had needed to take a painkiller near the end but it was "nothing special … I don't take magic pills to win the match. I served really bad in the fourth set and then in the fifth he broke me very early. He was playing with more confidence the fifth set."

On Chatrier, there was a twist and a tumble as Djokovic, getting up from an awkward fall in which he looked as if he had hyperextended his right leg, emerged from the mini-doldrums to break back for 4-4 in the fourth.

Reaching for his fourth slam in a row, Djokovic had to hold serve to stay in the tournament. When he murdered a simple volley after clipping the net, he gave Tsonga two match points and the stadium fell to a hush. He dodged the first bullet with a volley, and the next one, clipping the net with ripped forehand behind a big serve, before levelling at 5-5.

When asked a second time to keep his championship hopes alive, Djokovic flirted with the lines, just as he did to survive then thrive against Federer in the US Open semi-finals in New York last September. But Tsonga hit a backhand cross-court for his third match point – and netted a forehand for deuce. He got it back to win a rally that sent Chatrier delirious, a fourth match point – and Djokovic smashed to save.

Djokovic, looking frayed and buoyed by turn in the tie-break, engaged in several titanic rallies before Tsonga netted a return and the match went to a fifth set under a tungsten sky.

At the end, Tsonga was spent, barely reaching 100mph on serve. Djokovic broke him again, before serving out. The Frenchman lost but did not surrender like Gasquet the night before. Djokovic got his first match point at about 7.08pm. Within seconds, the match was his.