Both stars moved on after their respective opponents retired from their matches in the second set due to injury.
Djokovic was leading 6-3, 2-0 and up 30-0 in the third game when his opponent, Martin Klizan of Slovakia, retired due to an ailing ankle.
"It was great to be back on Centre Court, the cathedral of tennis, where I have many special memories," the 30-year-old Serb said. "It's never nice to win like this, but I tried to focus on my game plan. I thought I served well, but didn't do so well on my returns."
Djovokic will face 22-year-old Czech Adam Pavlasek, who overcame dropping the first set to post a 6-7 (7), 6-1, 6-3, 6-1 victory over American Ernesto Escobedo in two hours, five minutes.
While Djokovic advanced in 40 minutes, Federer needed just three more to reach the second round of Wimbledon for the 15th consecutive year. The 35-year-old Swiss star, who has seven Wimbledon titles to his credit, was leading 6-3, 3-0 before his opponent, Alexandr Dolgopolov of the Ukraine, stopped in the second set with an ankle injury.
"I was hoping Alexandr was feeling better today but he has had a rough one this year, he has had to pull out a lot of matches," Federer said. "You always wish for somebody that he can play his Wimbledon the way he wants to play it, and he wasn't really able to today, but he tried."
The victory was Federer's record-breaking 85th match win at the All England Club. He is one win ahead of Jimmy Connors for most victories in the grass-court major in the Open era, which began in 1968.
Sixth-seeded Milos Raonic recorded a 7-6 (5), 6-2, 7-6 (4) win over German Jan-Lennard Struff. The 26-year-old Raonic became the first Canadian male to reach a Grand Slam final when he advanced to face Andy Murray last year.
Other seeded winners on Tuesday included No. 8 Dominic Thiem of Austria, No. 10 German Alexander Zverev, No. 11 Tomas Berdych, No. 13 Bulgarian Grigor Dimitrov, No. 15 Frenchman Gael Monfils, No. 17 Jack Sock and No. 23 John Isner of the United States, No. 25 Albert Ramos-Vinolas of Spain, No. 27 German Mischa Zverev and No. 29 Juan Martin del Potro of Argentina.
Another upset victim was 19th-seeded Feliciano Lopez of Spain, who retired in the fourth set while trailing Italy's Adrian Mannarino 5-7, 6-1, 6-1, 4-3.
No. 32 seed Paolo Lorenzi of Italy was leading Argentina's Horacio Zeballos 7-6 (3), 4-6, 7-6 (8), 2-2 when their match was suspended by darkness. It was the only first-round match that was not completed.