The 20-year-old saved two match points in the deciding tiebreaker before winning 6-7 (2-7) 7-6 (7-5) 7-6 (14-12) in more than two and a half hours.
Kyrgios said the feeling of beating the Swiss legend surpassed the emotion of defeating Rafael Nadal at Wimbledon last year.
"I think this is definitely the greatest win over my career so far," Kyrgios said.
"It doesn't really feel real at the moment.
"I didn't really feel as if I was playing out there - it almost felt like I was watching.
"It was similar to that match at Wimbledon when I played Rafa. It's a strange feeling. It hasn't happened many times in my career... it's happened twice now. It's pretty exciting."
Getting some physio and massage then it's bed for me, if I can sleep. #Buzzing
— Nicholas Kyrgios (@NickKyrgios) May 6, 2015
The reaction on social media was one full of praise for Kyrgios with many excited by the manner of his victory against one of the world's best players.
Blessed to play one of my childhood heroes in Roger Federer. Blessed to get the win tonight 7-6 6-7 7-6 (14-12).
— Nicholas Kyrgios (@NickKyrgios) May 6, 2015
Tremendous win by Nick Kyrgios at Madrid Masters, downing Roger Federer in three tie-break sets, 14-12 in the 3rd.
— Glenn Mitchell (@MitchellGlenn) May 6, 2015
Kyrgios has the complete tennis game. But it's his ability to execute under pressure that remains his great asset. Craves the big moment.
— Adam White (@White_Adam) May 6, 2015
Federer on Kyrgios: "He's got a wonderful serve, good potential, so I hope he keeps working hard and that he can compete for the best spots"
— Tennis View Magazine (@TennisViewMag) May 6, 2015
Kyrgios vs Federer (1-0) Kyrgios vs Nadal (1-0) Kyrgios vs Djokovic (0-0) Kyrgios vs Murray (0-2)
— Christopher Clarey (@christophclarey) May 6, 2015
Winners: Federer 50 Kyrgios 45 UEs: Fed 36, Nick 41. Kyrgios wins the match
— Luigi Gatto (@LuisGatTWI) May 6, 2015
Nick #Kyrgios signs off a super-impressive win over Roger #Federer. http://t.co/HNDINmxRpO #tennis pic.twitter.com/2tVLcTzd8q
— TennisTV (@TennisTV) May 6, 2015