Wawrinka, the 23rd seed and 2016 champion, led Djokovic 6-4, 7-5, 2-1 when the Serb quit with a nagging left shoulder problem that had troubled him since the start of the tournament.
"The pain was constant for weeks now. Some days higher, some days with less intensity and obviously taking different stuff to kill the pain instantly," Djokovic said.
"Sometimes it works. Sometimes it doesn't. You just know when you know, I guess, when you feel like you're not able to hit the shot anymore." Djokovic refused to expand on the nature of his injury, which had caused him considerable pain during a second-round win over Juan Ignacio Londero.
"I retired and I told you it's left shoulder. I have nothing more to talk about," he said.
"I don't want to talk about my injuries. I said that in the past. I'm sticking to that."
Djokovic had claimed he felt "almost pain-free" following a straight-sets defeat of Denis Kudla in round three, but the problem resurfaced against Wawrinka in the first meeting between the pair since the final here three years ago.
The world number one received treatment before the start of the third set against Wawrinka but soon threw in the towel, the sixth time he has retired at a Grand Slam tournament.
"It is frustrating. Very frustrating. Obviously not the first, not the last player to get injured and to withdraw from one of the biggest events in sport," he said.
"But obviously I just came off the court, so of course it hurts.
"Obviously I'm in the midst of unfortunate situation, and I have to, you know, suffer the consequences of that. And as I said, I'm not the first nor the last one. Life goes on."
'Long road ahead'
But Djokovic, winner of four of the past five Slam events and 16 overall, remained bullish about his chances of eventually catching and surpassing long-time rival Roger Federer, who holds the men's record of 20 major titles.
"It's no secret that I have of course desire and a goal to reach the most Slams and reach Roger's record," Djokovic said.
"But at the same time, it's a long road ahead hopefully for me I hope I can play for many more years. I'm planning to. I don't see an end behind the corner at all.
"Now it's a matter of keeping my body and mind in shape and trying to still peak at these kind of events that are majors and that are the most significant in our sport."
It marked just the second time in the past decade Djokovic had pulled out of a Grand Slam match, having last retired during a 2017 Wimbledon quarter-final against Tomas Berdych with an elbow injury.
That setback prompted him to shut it down for the remainder of the season and led to questions about his future. His spectacular return to form 12 months later silenced those concerns, and he is hopeful of a swift recovery.
"This season is not yet over," he said, reflecting on a year in which he added another Australian Open and Wimbledon title to his collection.
"Obviously Grand Slam season is done for me. I mean, I won two Slams out of four and played semis in French. I had a really good Grand Slam season. I cannot complain, not at all.
"There is plenty of big tournaments ahead. Rankings-wise, plenty of points to defend for me and try to withhold that ranking of number one.
"I just hope I'll get a chance to be competing, because once I'm healthy I actually like my chances playing in Asia. And also indoor season, I play historically pretty well in those last couple months of the year."