After a slow start on Centre Court, Djokovic, who has 24 Grand Slam titles, won 4-6 6-3 6-4 7-6 (7-3).
He will play Holger Rune next after the Danish 15th seed mounted a comeback of his own, prevailing over Frenchman Quentin Halys in five sets having trailed by two.
“A very challenging match, I think mentally as well, to hang in there,” said Djokovic.
“I was not allowed to have too big concentration lapses. I think I’ve done well in that regard. That was one of the best tie-breaks I’ve played this year, that’s for sure.”
Popyrin, who had never been beyond the second round in four previous visits to Wimbledon, came out with intent and took the first set with a break of serve in game seven.
But a lengthy break before the start of the second set as the roof was closed played into Djokovic’s hands, as the Serb started to find his rhythm.