Nadal, 33, had not dropped a set this tournament before 23rd seed Kyrgios provided his biggest test so far.
Kyrgios, who wore a Kobe Bryant basketball shirt in the warm-up, battled hard but Nadal came through 6-3 3-6 7-6 (8-6) 7-6 (7-4).
Nadal will face Austrian fifth seed Dominic Thiem in the last eight.
Nadal and Kyrgios have not always seen eye to eye with the rivalry blowing up last year after a tempestuous meeting in Acapulco.
Afterwards the 19-time Grand Slam champion said Kyrgios’ behaviour “lacked respect” before the Australian responded by calling him “super-salty”.
Yet the appreciation for each other’s ability, despite their wildly contrasting styles, has rarely been in doubt and was typified by their firm handshake at the net following a riveting contest on Rod Laver Arena.
“When Nick is playing like he did today with this positive attitude he brings a lot of things to our sport,” said Nadal, who won his only Australian Open title in 2009.
“I encourage him to keep working like this because he is one of the biggest talents of our tour.”
Nadal came into the match having not dropped a set in the opening three rounds, sealing his place in the last 16 with his “best match so far” against fellow Spaniard Pablo Carreno Busta.
Kyrgios’ route was much more strenuous, having needed four-and-a-half hours to beat Russian 16th seed Karen Khachanov on Saturday night.
The effects of that gruelling match and, possibly, the death of his basketball hero Bryant seemed to contribute to a muted start from the soon-to-be Australian number one.
While Nadal was finding lines with blistering winners in the opening few games, Kyrgios’ returning game was much looser and lacked fizz.
A wide backhand allowed Nadal to take his second break point for a 3-1 lead, proving pivotal as the Spaniard then breezed through the first set in 36 minutes.
As Kyrgios struggled to hold serve in the opening game of the second set it looked like Nadal could quickly run away with the match.
Kyrgios saved three break points – including one after playing a shot between his legs in a rally – before clinching a hold which proved pivotal.
In the next game he earned his first break point of the match, urging the home support to crank up the noise by punching his racquet in the air.
They responded and he responded too. A wonderful point – full of incisive forehands, punching backhands and teasing drop-shots – went Kyrgios’ way with a winner which kissed the baseline.
Kyrgios celebrated by, almost poignantly, leaping into the air with a slam dunk-style basketball jump and carried the momentum throughout the set to level.
“Seems like in the beginning I was in control but you know against Nick you are never in control,” Nadal said.
“If you make a mistake then it is difficult to break him.”
Kyrgios nuked his racquet on the way to losing the tie-break but, instead of unravelling like he has in the past, regained his composure in the fourth.
Nadal broke to love for 2-1, a slender lead which he continued to hold until he served for the match.
Kyrgios was not done yet, however.
Two break points came his way when Nadal produced another double fault, taking the second with a crushing forehand.
But, like Wimbledon and like the third set, Nadal zoned back in to nick the tie-break.
Another baseline drop-shot from Kyrgios floated into the net to give Nadal a crucial 5-3 advantage and he saw out victory to reach the Melbourne quarter-finals for a 12th time.
It had been billed as the latest instalment of a fiery rivalry between two players with polar opposite personalities.
But the match started in a more subdued atmosphere following the shock news of the death of American basketball great Bryant.
Kyrgios is a huge basketball fan and paid tribute by wearing an LA Lakers vest bearing Bryant’s name on the back as he walked out on court.
The 24-year-old Australian, who looked close to tears, kept the jersey on during the warm-up.
Bryant was a keen tennis fan and performed the coin toss before Roger Federer’s US Open match against Britain’s Dan Evans last year.
Nadal had also paid his own tribute earlier in the day, posting an image of Bryant on his Instagram account and telling of his “shock” at the death of “one of the world’s great sportsmen”.