The setback was a third straight loss for the 30-year-old Serb, who is trying to make a comeback after an elbow injury sidelined him for the final six months of last year.
The 21-year old, ranked 175 in the world, held his nerve during a third-set tie-break in their round of 32 match to see off the Swiss legend and record the biggest result of his career to date.
Federer won the first set with relative ease, but made uncharacteristic errors in the second set, and Kokkinakis took advantage with his big serve and powerful forehand.
Federer was in control of the game as usual after he destroyed Kokkinakis in the fourth game of the opening set.
Instead he'll be replaced by Spain's Rafael Nadal when the rankings are released at the end of the tournament.
"When he won nine out of 10 French Open's he was winning 56% of all his points, so that shows how well he was playing". "Don't know why I could never get to any level".
"I felt I started the match well, first six games", Djokovic said. I'm disappointed. I'm frustrated a little bit that I couldn't find a way.
He also doesn't seem to be intimidated by the 20-time Grand Slam champion and was clutch when he needed it the most.
"It was important returning to number one in Rotterdam, keeping it now or getting it back within the season is not important".
Meanwhile, American tennis star Venus Williams battled from behind in both sets against Russia's Natalia Vikhlyantseva to book her place in the third round.
Radwanska, the 2012 Miami champion, hadn't posted back-to-back match victories since January. Federer said the demotion was appropriate.
Djokovic sat out the last half of 2017 because of problems with his racket-swinging arm, saying it had been bothering him for more than a year. "The truth is that it wasn't easy".
The Argentinian will now face Japanese Kei Nishikori (26), who beat Australian John Millman 7-6 (4), 4-6, 6-3 on Friday.
Benoit Paire handed former world number one Novak Djokovic a surprise defeat by in the Miami Open second round. You probably have to break it down to the key moments. Federer had invited Kokkinakis to Dubai to train with him on a couple occasions.
Argentina's Juan Martin del Potro is also through as the Indian Wells Masters winner overcame Dutchman Robin Haase 6-4, 5-7, 6-2. Meneses, a member of the student government and senior class board, has also performed the National Anthem at other professional sporting events including the Astros vs. Nationals.