Limping but inspired, Nick Kyrgios defeated Russia’s 16th seed Karen Khachanov 6-2, 7-6 (5), 6-7 (6), 6-7 (7), 7-6 (10-8) to advance to the fourth round of the Australian Open. He suffered a left buttock injury but was a far bigger pain in the backsides of Khachanov and the umpire, raging his way to a highly anticipated match with Rafael Nadal.

Not for the first time, Kyrgios turned a straight-sets breeze into an unhinged psychodrama. This one even came with an omen: a brawl broke out in the arena before play commenced. Those who were not evicted were treated to a more interesting fight – between techniques, temperaments, and in Kyrgios’s case, layers of internal turmoil. He would later dub it one of his greatest wins.

The first set was not the mere formality the scoreline suggests. As in the first two rounds, Kyrgios came out in a hurry: his second service game was a 46-second blur. In the sixth game he broke somewhat luckily, floating his worst drop shot of the tournament into Khachanov’s path only for the Russian to blast his backhand wide. It was a preview of the unexplainable turns the contest would take over four hours and 26 minutes.

Quick Guide Australian Open: last-16 draws Show Men's singles (1) Rafael Nadal v Nick Kyrgios (23)

(10) Gaël Monfils v Dominic Thiem (5)

(4) Daniil Medvedev v Stan Wawrinka (15)

(17) Andrey Rublev v Alexander Zverev (7) Tennys Sandgren v Fabio Fognini (12)

Marton Fucsovics v Roger Federer (3)

Milos Raonic (32) v Marin Cilic

Diego Schwartzman (14) v Novak Djokovic (2) Women's singles (1) Ashleigh Barty v Alison Riske (18)

(22) Maria Sakkari v Petra Kvitova (7)

Coco Gauff v Sofia Kenin (14)

Ons Jabeur v Wang Qiang (28) Anett Kontaveit v Iga Swiatek

(16) Elise Mertens v Simona Halep (4)

Garbiñe Muguruza v Kiki Bertens (9)

(17) Angelique Kerber v Anastasia Pavlyuchenkova (30)

Moments later, panicked whispers spread through the arena as Kyrgios grimaced and clutched his left buttock. The Australian held serve, but seconds later headed into the bowels of the stadium with the trainer. Like a pantomime villain, he returned and broke Khachanov for a second time, taking the set in 34 disjointed minutes.

The second set started with another love service game by Kyrgios, but Khachanov dug in. The tie-break rested on a knife edge until Kyrgios won a 24-shot rally to create the only set point he needed: a punishing serve down the middle sealed it in 59 minutes.

A winner from Nick Kyrgios is cheered to the rafters by fans at the Melbourne Arena. Photograph: Michael Dodge/AAP

Khachanov conceded a dispiriting break in the third set and the result seemed foregone. It was not. Never one to make things easy on himself, Kyrgios conceded a break of his own. In the tie-break, Kyrgios took the same kamikaze approach of astonishing winners and total brain-fades as in earlier contests to let Khachanov prolong the contest.

In the early stages of the fourth set, Kyrgios seemed to be proving his mettle. He was also a little reckless, flinging himself around like a wicketkeeper, risking and acquiring further injury. Bleeding from the hand, he received a time violation for sparing the ball boy the job of dispatching his bloodied towel.

“Are you stupid? Can you not see?” Kyrgios screamed at the umpire. “Do your job.” In this instance at least, he did have a point. But in the tie-break, Kyrgios could not do his own, surrendering a match point and then curling a forehand wide. Five sets it was.

After beating Gilles Simon in the second round, Kyrgios had promised to improve his behaviour towards his box. He was as good as his word until the third game of the fifth set, screaming in the direction of his entourage. Moments later there was an underarm serve. It was all a bit ragged. Still Kyrgios pressed, and again it went to a tie-break.

To describe the closing moments as tense is selling it short. Kyrgios won the first three points in a canter and then dropped four just as quickly, slipping back into his familiar monologue of self-recriminations. But a backhand winner down the line to make it 8-8 had him finally flashing the one expression he hadn’t tried all night: a smile.

After an unforced error from his opponent, the smile became a jubilant laugh when Khachanov battered a backhand wide and Kyrgios dropped to the court in a state of sheer relief. “I don’t even know what to say right now,” Kyrgios said. “It was insane.”

Next up is Nadal, with whom he shares a colourful history. Earlier in the tournament, Kyrgios parodied the Spaniard’s fidgety pre-serve routine and the comedic turn was a hit. To progress further, he will have to show the world he can play the straight man too.