World number one Djokovic took the opening two sets but was then hampered by a side injury that restricted his movement, although he still recorded a 7-6 (7-1), 6-4, 3-6, 4-6, 6-2 victory, BBC Sport reported.
Djokovic is set to meet 14th seed Milos Raonic in the next round, but said, "I know it's a tear and I don't know if I will recover from that in two days. I don't know if I will step on court."
The Serb, who is chasing a record-extending ninth men's singles title in Melbourne and a third in a row, added, "This is one of the most special wins in my life.
"It doesn't matter who I was up against or at what round, to pull this through is something I will remember forever.
"In the third and fourth set I just served and couldn't do much with the returns. I was just putting in two first serves.
"I just tried to stay in there. I was hoping that whatever is happening is going to feel better and towards the end of the fourth it started to feel better."
Djokovic hobbled between points, clutched his side and received medical treatment, but 23-year-old Fritz, the 27th seed, could not take advantage.
Canadian Raonic moved into the fourth round with a win over Hungary's Marton Fucsovics.
Five days without fans
Australian Open players savored the atmosphere of a crowd hours before Melbourne Park closes its doors to fans because of a snap five-day lockdown.
The sight of unmasked spectators and the sound of raucous cheers at the Grand Slam has been a glorious reminder of the best parts of live sport at a time when empty stadiums and piped fan noise on TV are the norm.
But it was always a fragile privilege.
Victoria State is entering lockdown to suppress a coronavirus outbreak.
From midnight on Friday until Wednesday people must stay at home, schools are closed and gatherings are banned as Victorian premier Daniel Andrews said a "short, sharp circuit breaker" was needed to combat an outbreak of the UK strain of coronavirus.
It meant that fans were still allowed into Melbourne Park on Friday to watch players including Serena Williams and Naomi Osaka.
"It's rough. It's going to be a rough few days for I think everyone. But we'll hopefully get through it," 23-time Grand Slam champion Williams said.
"It's not ideal. It's been really fun to have the crowd back, especially here. It's been really cool," she added. "But, you know what, at the end of the day we have to do what's best. Hopefully it will be all right."
The players entered a biosecure 'bubble' from Saturday morning similar to ones they have experienced at tournaments for much of the pandemic, whereby they are not allowed to leave their hotels or the tournament grounds.
"They've been doing this all year," Australian Open tournament director Craig Tiley said.
"The last five days have been a unique experience for them and the next five will be back to what they know."
Up to 30,000 fans had been allowed in each day – around 50 percent of the usual attendance – although the actual numbers attending have fallen well short of that and only 21,000 came through the gates on Thursday.
Fans who had already bought tickets will get their money back and Friday's night session was still open, despite Andrews encouraging Victorians to stay at home.