The most improbable men’s tennis story of the year gets the finale that, in the end, may have been inevitable. After Valentin Vacherot defeated an ailing Novak Djokovic in the first Shanghai Masters semifinal, his cousin, Arthur Rinderknech, beat Daniil Medvedev in three sets to set up a family affair Sunday.

Vacherot escaped his recovery and media duties just in time to watch Rinderknech edge past Medvedev. A fractious final set ended with Rinderknech in disbelief and delight on the court, and Medvedev arguing with Mohamed Lahyani over perceived favoritism when it came to penalizing players for time violations.

Rinderknech avoided a second time violation in one game — which would have seen him lose his first serve — when break point down at 3-3 in the third set, despite the serve clock counting down to zero. He then held on until the 10th game of the set, in which Medvedev saved one match point with a 128-mph second serve, but double-faulted when trying to repeat the trick, sparking the contrasting scenes of joy and fury. Rinderknech’s 4-6, 6-2, 6-4 win is his fourth against a top-20 player in a row, with his best victory of the tournament by ranking coming against world No. 3 Alexander Zverev.

The chaos at the end of his win over Medvedev was fitting for a bizarre tournament of stifling conditions, upsets all over the draw, and confrontation at seemingly every turn. Vacherot beat top-30 player Tallon Griekspoor in the match after Griekspoor had physically outlasted world No. 2 Jannik Sinner, prompting Griekspoor to say that he had chosen a “rotten sport” in an interview with Ziggo Sport. But when all that faded away, Vacherot and Rinderknech were left hugging on the court, at the center of the impossible.

“In the best dreams we couldn’t have dreamt about this. I can’t even say it’s a dream. I don’t think even one person in our family dreamt about it. It wasn’t a dream. It’s just a dream that came out of nowhere, and we started believing it maybe in the quarters,” Rinderknech said in his on-court interview.

“I already joined him in 2017 in Texas A&M, and now I’m joining him in the top 100. It’s pretty cool,” Vacherot, 26, had said of Rinderknech, 30, after beating Holger Rune in the quarterfinals. Both men — Vacherot Monégasque, Rinderknech French — played college tennis at Texas A&M. They have enjoyed the best weeks of their careers simultaneously, with both of them reaching their first ATP Tour final.

Now, one of them has to lose. After the past 11 days, neither is likely to mind all that much.