The withdrawal ends Djokovic's streak of reaching the finals at 17 straight events.
Djokovic retired after Lopez won the opening set 6-3.
"It's an eye problem," Djokovic said at a press conference. "I have had it ever since I arrived in Dubai. It started with an infection and then severe allergy.
"It's gotten worse in the last two days, unfortunately. It's the first time that I have had such a problem with the eye. It was ultra-sensitive today."
Djokovic's streak of consecutive finals appearances began with the 2015 Australian Open. He won 13 of the 17 finals, including the last seven.
He was one final from tying Ivan Lendl's record of 18 in 1981-82.
"(That) is the least of my thoughts in the moment," Djokovic, said. "I just hope that this problem will fade away in the next couple of days."
Lopez will face Marcos Baghdatis in the semifinals. The unseeded Baghdatis upset fourth-seeded Roberto Bautista Agut 7-5, 6-0.
Friday's match between Wawrinka and Kyrgios will be packed with tension as it will be the first time they have faced one another since an on-court incident last August in Montreal.
During that match, Kyrgios was overheard making a crude sexual remark about women's tennis pro Donna Vekic, Wawrinka's girlfriend, via the on-court microphone system.
Kyrgios was fined $25,000 and suspended for 28 days by the ATP. He later apologized for the remarks.
Andrea Petkovic of Germany knocked out fourth-seeded Garbine Muguruza 6-1, 5-7, 6-2 and third-seeded Agnieszka Radwanska rallied to beat Roberta Vinci 3-6, 6-2, 6-3 to advance to the Qatar Open semifinals on Thursday.
Also reaching the semis were Jelena Ostapenko of Latvia and eighth-seeded Carla Suarez Navarro.
Suarez Navarro beat Elena Vesnina of Russia 6-3, 7-6 (3). She will face Radwanska in the semifinals.