After knocking off fourth seeded Spaniard David Ferrer in a three-hour marathon on Tuesday, the 21st ranked Japanese was forced to go the distance again, surviving a two-hour centre court battle with Federer.
Nishikori has been one of Federer's few bogeymen, having now gotten the better of the Swiss maestro in two of their three career meetings.
"To beat Roger, and it's second time to beat him... I thought I really played well, especially in the third," Nishikori told reporters. "I was hitting both deep and striking well. Everything was going well.
"There was couple of tough moments, but I was fighting through and happy to win today."
Arriving in south Florida riding the momentum from a finals appearance at Indian Wells, Federer had been in superb form, cruising into the Miami quarter-finals without dropping a set, highlighted by 49 minute fourth round win over Richard Gasquet.
A two-time Miami champion, Federer convincingly won the opening set and looked ready for an easy night when he twice went up a break in the second.
But each time, the feisty Nishikori would immediately answer back then broke Federer again at 6-5 to level the match.
With the third set heading towards a tie-break it was Federer who blinked while serving to stay in the match at 5-4, slamming an easy forehand into the net and then sending a return long to hand Nishikori triple match point.
Federer would survive the first two but could not save the third, Nishikori whipping a forehand winner off the return to seal the upset.
"I just couldn't find my rhythm on the serve today," Federer said. "It was surprising especially after how well I have served and played this week.
"I had the set and a break and up a break again so it is a little frustrating.
"He was more consistent in the second and third so all credit to him."
The victory setup a semi-final meeting against world number two Novak Djokovic, who ended Andy Murray's reign as Miami champion by easing past the sixth seeded Briton 7-5 6-3.
For Djokovic, the victory over Murray was a small measure of revenge as the met for the first time since the Scotsman beat him in last year's Wimbledon final.
Murray, playing his first event since splitting with coach Ivan Lendl last week, had looked increasingly comfortable and confident on his own but Djokovic kept the Scotsman under almost constant pressure in blustery conditions.
"I was not surprised about the way he played," said Djokovic, whose coach Boris Becker was also not in Miami as he is taking time off to undergo double hip surgery. "I expected him to play well, to be a little bit more aggressive.
"I tried to not allow him to be in the comfort zone because when he strikes the zone, when he feels comfortable on the court, he's striking the ball so well, maybe best in the world."
In dramatic contrast to the women's semi between Dominika Cibulkova and Agnieszka Radwanska that ended moments earlier on centre court and featured 19 breaks of serve, breaks were hard to come by for Djokovic and Murray in a tight opening set.
Murray had only a single break opportunity against the Serb while Djokovic was able to convert one of his three chances, with the help of a controversial point.
The first set ended in an argument between Murray and the chair umpire, the Scotsman furious that Djokovic was given a point to open the decisive game even though it was clear the Serb reached across the net to hit the ball.
A distracted Murray then lost the next three points on unforced errors as Djokovic claimed the break and set.
"I wasn't sure, from where I was standing, it was a very hard thing to see," Murray said. "I knew it was close. So that's why I went and asked Novak and he told me he was over the net. That was it.
"(The chair umpire) said, 'yes, he was over the net but he was in line with the net,' so I didn't really understand.