Kyrgios fought from a set down and then saved three match points after trailing 6-3 in the deciding tie-break, storming back to win 3-6 7-6 (2) 7-6 (6).
The 23-year-old claimed he was considering retiring after the first set because of nausea but carried on because he did not want to deal with the reaction. He was then booed for attempting an underarm serve, and the handshake at the end was distinctly brief.
— Tennis TV (@TennisTV) February 28, 2019
Speaking at his press conference, Nadal told reporters: "He is a player who has enormous talent. He could win grand slams and fight for the top positions of the ranking, but there is a reason why he is where he is. He lacks respect for the public, the rival and towards himself."
Kyrgios has slipped to 72nd in the rankings after a difficult start to the season but this was his third win in six meetings with Nadal, and he made clear the Spaniard's opinion does not interest him.
"I'm different, Rafa's different," Kyrgios told reporters in Mexico. "He can focus on what he needs to do. He doesn't know the journey I've been through, doesn't know anything about me, so I'm not going to listen at all."
Kyrgios then posted a clip of the match point on Instagram with the caption: "Don't doubt yourself, there are plenty of people who will do that for you. I can smell the blood when I play this dude."
In the quarter-finals, Kyrgios will face another player with whom he has history, Stan Wawrinka, who defeated seventh seed Steve Johnson 7-6 (5) 6-4.
Britain's Cameron Norrie produced another upset, ousting number four seed Diego Schwartzman 7-6 (5) 4-6 6-3, and will face Mackenzie McDonald, who knocked out his fellow American Frances Tiafoe.
There were also wins for second seed Alexander Zverev, John Isner, John Millman and Alex De Minaur.
Roger Federer continued to close in on his 100th career singles title after a three-set win over Fernando Verdasco at the Dubai Tennis Championships.
The 37-year-old, who can become only the second man in the Open era after Jimmy Connors to take his career title success into three figures, beat the Spaniard 6-3 3-6 6-3 to move into the quarter-finals.
Federer will face Hungary's Marton Fucsovics next after the world number 35 beat Jan-Lennard Struff of Germany 6-4 6-2. But top seed Kei Nishikori crashed out after suffering a shock 7-5 5-7 6-2 defeat to Polish qualifier Hubert Hurkacz.
The Pole will next meet rising Greek star Stefanos Tsitsipas while Gael Monfils continued his fine form and sixth seed Borna Coric recovered from a nightmare first set to beat Tomas Berdych 1-6 6-1 7-6 (4).
At the Brasil Open, Felix Auger-Aliassime knocked out fifth seed and three-time champion Pablo Cuevas in the opening round.
The Canadian teenager, who reached his first ATP Tour final in Rio last weekend, saved four of the five break points he faced to claim a 5-7 6-3 6-3 victory.
The man who beat him on Sunday, Serbia's Laslo Djere, also clinched a first-round win, defeating Italian qualifier Alessandro Giannessi 7-6 (5) 4-6 6-4, while Christian Garin, Leonardo Mayer, Guido Pella and Marco Trungelliti reached the quarter-finals.