World number one Djokovic defeated Kei Nishikori 6-7 (4/7), 6-3, 6-3, 6-2, taking his 17th consecutive victory over the Japanese star and improving to 18-2 in their overall rivalry.
"I was very pleased with the focus," Djokovic said. "Maybe at some points I wasn't my best, but I was determined and focused and that made the difference."
With a fourth career US Open trophy, Djokovic would complete the first men's singles sweep of major titles in the same year since Rod Laver in 1969.
Reigning Wimbledon champion Barty won 11 of 14 games after dropping the first set, only for Rogers to capture five of the last six games for a shocking 6-2, 1-6, 7-6 (7/5) triumph.
"I didn't want to leave," Rogers said. "I just said make balls, try to stay in this match, it can't get any worse, you've lost to her every time."
Rogers had dropped all five prior meetings with Barty but would not be denied, breaking the Aussie as she served for the match in the eighth and 10th games as the crowd went wild at Arthur Ashe Stadium.
"I was just trying to stay in the point longer than Ash," Rogers said. "I was happy with myself for sort of problem solving. I'm just so excited to be moving on to the next round."
Rogers will next face 150th-ranked British qualifier Emma Raducanu, an 18-year-old who routed Spain's Sara Sorribes Tormo 6-0, 6-1 in 70 minutes.
Djokovic, meanwhile, marched toward a 21st career Grand Slam title, which would break the deadlock for the men's record he shares with Rafael Nadal and Roger Federer, both absent with injuries.
The 34-year-old Serbian star advanced to a fourth-round matchup on Monday against 99th-ranked US wildcard Jenson Brooksby.
"He was playing pretty solid," Nishikori said. "I couldn't break the wall. Very unfortunate I lost."
Djokovic, who had 52 unforced errors and 45 winners, dropped the last three points of the first-set tie-breaker, the last on a Nishikori service winner.
"I don't think I started off very well," Djokovic said. "I was too passive. He was dictating the play. I was still trying to find the tempo. It took me a little bit of time to adjust to his game."
But Djokovic broke early in each set from there to seize command. In the fourth he grabbed a 3-2 lead and never dropped another game.
"Big credit to Kei, who played on a very high level," Djokovic said. "He was quick. It was tough. Great fight from him."
Tokyo Olympic champion Alexander Zverev defeated 184th-ranked Jack Sock 3-6, 6-2, 6-3, 2-1 when the American retired with a right thigh injury.
"I know I'm playing OK but a lot of other guys are playing well, too," Zverev said. "I'm hoping to keep my form and give myself my best chance."
Fourth seed Zverev, the 2020 US Open runner-up, joined qualifiers Oscar Otte and Peter Gojowczyk as the first German trio in the US Open fourth round since 1994 and any Slam last 16 since Wimbledon in 1997.
Wimbledon runner-up Matteo Barrettini, the Italian sixth seed, eliminated Ilya Ivashka of Belarus 6-7 (5/7), 6-2, 6-4, 2-6, 6-3. Next up is 144th-ranked Otte, who beat Italy's Andreas Seppi 6-3, 6-4, 2-6, 7-5.
Sakkari beats Kvitova
Greek 17th seed Maria Sakkari, a French Open semi-finalist, ousted two-time Wimbledon champion Petra Kvitova 6-4, 6-3, booking a fourth-round match against 2019 US Open winner Bianca Andreescu.
Czech 10th seed Kvitova double faulted on the final point to hand Sakkari the victory after 81 minutes.
Canadian sixth seed Andreescu improved to 10-0 at the US Open, advancing over 104th-ranked Belgian lucky loser Greet Minnen 6-1, 6-2.
Tokyo Olympic champion Belinda Bencic, a 2019 US Open semi-finalist, defeated US 23rd seed Jessica Pegula 6-2, 6-4.
The Swiss 11th seed will next face Polish seventh seed Iga Swiatek, last year's French Open champion, who beat Estonian Anett Kontveit 6-3, 4-6, 6-3.
Czech fourth seed Karolina Pliskova, this year's Wimbledon runner-up and a 2016 US Open finalist, beat Australian Ajla Tomljanovic 6-3, 6-2.