Djokovic, winner of four of the past five Slam titles and 16 in all, was treated for a sore left shoulder throughout his 6-4, 7-6 (7/3), 6-1 victory over Argentina's 56th-ranked Juan Ignacio Londero.
"It was definitely affecting my serve and backhand," Djokovic said of his shoulder injury. "I was definitely tested."
Djokovic next faces 27th-seeded Serbian compatriot Dusan Lajovic or American Denis Kudla, but the injury casts grave doubts on his bid to be the first US Open repeat winner since Federer won from 2004-2008.
"This is something I've been carrying for quite a while now," Djokovic said. "It wasn't easy to play with the pain, but you have to hope you will get some opportunities and some lucky shots.
"It's not the first time I'm facing this kind of adversity or challenge. It is what it is and I'm just grateful to be on the court."
Djokovic won't play again until Friday and until then, "I'll probably freeze my arm for 48 hours, not do anything with it and see what happens."
Federer, a 20-time Grand Slam winner seeking his first US Open crown since 2008, rallied to beat 99th-ranked Bosnian Damir Dzumhur 3-6, 6-2, 6-3, 6-4.
The 38-year-old Swiss third seed, who also dropped the first set against Indian qualifier Sumit Nagal in his opener, answered the wake-up call after conceding the first set with 17 unforced errors.
"When it happens like this, back-to-back matches, it's just a bit frustrating more than anything, especially when the level is that low and there is that many errors and the energy is not kind of there," Federer said. "But can only do better, which is a great thing moving forward.
"I didn't expect to hit 15 to 20 unforced errors, which is basically the entire set just sort of donated... I clearly have to play better from the get-go."
US eighth seed Serena Williams, seeking her 24th career Grand Slam title to match Margaret Court's all-time record, faces 17-year-old US wildcard Caty McNally in a later match under the roof at Arthur Ashe Stadium.
Only 10 of 32 singles matches were played as rain wiped out play except in enclosed stadiums, with Russian fifth seed Daniil Medvedev and three-time Grand Slam champion Stan Wawrinka among those postponed to Thursday.
"I definitely profit from everything I did in the game and my ranking to be put on center court on a day like this," Federer said.
Serbian star Djokovic broke on an errant Londero forehand to close the first set, then was broken twice in falling behind 3-0 in the second set only to win the next five games.
"Somehow I managed to find my way back," Djokovic said.
Londero broke him, held at love and forced a tie-breaker, but Djokovic won five of the last six points thanks to Londero errors and then dominated the final set.
"I want to congratulate Londero for showing a fighting spirit," Djokovic said. "It was a real fight."
Five-time US Open winner Federer, who lost to Djokovic in last month's epic Wimbledon final, started poorly but broke early in each of the last three sets and held serve to the end.
"I buckled down and told myself I was going to hang tough and not get broken and that made a big difference," Federer said.
Next in Federer's path is either French 25th seed Lucas Pouille or Britain's 58th-ranked Dan Evans.
- Nishikori, Barty win -
Japanese seventh seed Kei Nishikori, the 2014 US Open runner-up, beat 108th-ranked American Bradley Klahn 6-2, 4-6, 6-3, 7-5.
Nishikori, who could face Federer in the quarter-finals, stumbled after seizing a 5-1 edge in the final set and needed five match points to win.
"A little bit of lost focus after 5-1," Nishikori said. "He started playing better too."
French Open champion Ashleigh Barty, the second seed from Australia, eliminated 73rd-ranked American Lauren Davis 6-2, 7-6 (7/2), saving a set point before dominating the tie-breaker.
"I knew I was doing the right things," Barty said. "It was just about execution. I'm glad I came through in the tie-breaker."
Czech third seed Karolina Pliskova, seeking her first Grand Slam title, ousted 202nd-ranked Georgian qualifier Mariam Bolkvadze 6-1, 6-4.
Ukraine fifth seed Elina Svitolina defeated seven-time Grand Slam winner Venus Williams 6-4, 6-4 and US 10th seed Madison Keys, the 2017 US Open runner-up, trounced China's Zhu Lin 6-4, 6-1.