Cilic tweeted his regrets.
"I am sorry to announce that I must withdraw from today's match. I have had a terrible night dealing with a case of food poisoning," he wrote.
"I am extremely disappointed to have my time in Madrid end in this way. Thank you for the support."
In the semi-final on Saturday, top-seeded Djokovic will face either Roger Federer or 2018 finalist Dominic Thiem who meet later on Friday in their quarter-final.
Cilic, winner of the US Open five years ago, entered Madrid with a 4-6 record and two clay losses but had started getting his game in gear.
The Croatian saved four match points against Martin Klizan in his opening match on Monday and needed three sets to win each of his next two encounters.
Djokovic won the Madrid title in 2016 and 2011.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ