However, Nishikori was prevented from launching a comeback as Djokovic, a three-time Wimbledon champion, regained his composure and managed to grind out wins in the third set (6-2) and in the fourth set (6-2) to set up a semifinal match against Juan Martín del Potro or Rafa Nadal.
But the three-time champion here turned the tables on Nishikori, holding his serve and then breaking in the next game to start a run of four successive games which allowed him to take the third set 6-2.
The No 2 seed had looked set for a comfortable afternoon when he won the first two sets, the second on a tie-break.
Following the incident, Nishikor - the 24th seed who saved three break points to hold serve at 2-1 in the second set - promptly broke and then held to go 4-1 up.
'I thought it was unnecessary to get the warning, ' he said.
Now ranked only 21st in the world, with his career stalling since his 12th Grand Slam title at the 2016 French Open, last year's Wimbledon saw him retire in the quarter-finals with a season-ending elbow injury.
Seeded 12, Wednesday will Djokovic's 41st appearance in a Grand Slam quarter-final.
"I was really glad to play Queen's and to get five matches there".
"I'm not sure what to say right now", U.S. Open finalist Anderson said.
"It's not the first time in the semi-finals - I've been here before - but first I'll try to enjoy this victory before thinking about the next opponent".More news: Trump dubs himself 'stable genius' for getting North Atlantic Treaty Organisation allies to pay up
"Post-match I heard that the organisers were planning to cancel my match if Monfils and Anderson went to a fifth".
"I want to use today's result as a spring from which to aim for a final place".
And he did not disappoint with a battling performance reminiscent of days gone by, even if he did fall out with umpire Carlos Ramos. I don't know how you would break him and that's why it's exciting he is back in the mix.
Defending champion Federer lost a Court One thriller, 2-6, 6-7 (5-7), 7-5, 6-4, 13-11 as 32-year-old Anderson became the first South African in the Wimbledon semifinals since Kevin Curren in 1983. "I didn't harm the grass", he said.
"That was I think the biggest chance I had".
"After that he was playing better".
He then let rip at Ramos for failing to sanction Nishikori for a similar act in the fourth set.
Djokovic last appeared in the semifinals at Wimbledon in 2015, when he won.