By Ian Ransom
After netting a shot to concede the set, Troicki approached the world number three, embraced him and called off the match after 39 minutes.
"Like any tennis player, you don't wish to win like this," 2008 champion Djokovic said in a courtside interview.
"I knew before the match that he had a little trouble with his stomach. I know it's the third round of a grand slam and he wanted to give 100 percent ... And he was not able."
Organizers later said Troicki had retired due to a stomach muscle strain.
Djokovic will next play the winner of Nicolas Almagro and Ivan Ljubicic.
(Reporting by Ian Ransom; Editing by Peter Rutherford)