The reigning Wimbledon champion won 4-6 6-2 6-1 to progress to the third round of the men's singles at the Cincinnati Masters.
"I was not feeling well, I did not have a great night and was not feeling that well for the first set and a half," said Djokovic, who has won every Masters 1000 title except Cincinnati.
"I kind of made it through and, with the help of the doctor and God, I am just - you know - happy that I managed to overcome the challenge.
"Credit to him playing well the first set but I was not myself."
In the women's singles, Garbine Muguruza played for the first time since losing in the second round at Wimbledon.
The Spaniard, a two-time grand slam champion, lost 2-6 6-4 6-4 in round two in Ohio to Ukrainian Lesia Tsurenko.
"It was a very ugly match, but I am happy that I fought, even if the level was not very high," said Muguruza, whose hardcourt buildup to the US Open has started later than her rivals because of an arm injury.
"At the end she managed to come back in the third set and play better and found a way to win the match.
"But I am happy I did not feel pain. Obviously I did not have a lot of practices to try to recover, so I had to manage a little bit."
The Cincinnati Masters, which began in September 1899, is the oldest tennis tournament in the United States played in its original city.