The two rivals, both bidding to become Olympic medalists for the first time, were winners in singles and doubles in the opening round Monday.
Playing the first match on center court, Nadal overcame numerous missed chances by sweeping the final four games to beat Potito Starace of Italy 6-2, 3-6, 6-2.
The top-seeded Federer made his entrance less than an hour later. He beat Dmitry Tursunov 6-4, 6-2, then received congratulations from one of the spectators, U.S. basketball star LeBron James.
Next came doubles.
Nadal played doubles but not singles at the Athens Olympics in 2004. At Beijing he's staying in the athletes' village, savoring the atmosphere and hoping to sustain a summer surge that has assured him of the No. 1 ranking next week.
"I am very happy to be here," Nadal said. "Just trying to enjoy 100 percent the experience, and later try my best on court."
No. 7 seed Venus Williams, playing her first match since winning Wimbledon for the fifth time, beat Switzerland's Timea Bacsinszky 6-3, 6-2. Williams, who swept the gold medals in singles and doubles in 2000, showed no sign of the knee injury that sidelined her in recent weeks.
Her sister Serena, seeded fourth, won all four games when her match resumed after an overnight rain interruption, and she beat Olga Govortsova of Belarus, 6-3, 6-1.
Like Nadal, Serena Williams was playing her first singles match at the Olympics. She won a gold medal in doubles in 2000 with sister Venus.
"It's a great thing going out there playing for your country," Serena said.
The No. 3-seeded Djokovic beat Robby Ginepri of the United States 6-4, 6-4. American Sam Querrey lost to Igor Andreev of Russia 6-4, 6-4, leaving James Blake as the only U.S. male to reach the second round of singles.
Blake and Querrey were eliminated in doubles by Andreev and Nikolay Davydenko, 6-3, 6-4.
The match, which lasted 3 hours, 17 minutes, surpassed
the record amount of games in a best-of-three-sets men's match
at the Olympics since tennis returned to the Games in 1988.
The previous record also belonged to Australians when Todd
Woodbridge and Mark Woodforde beat Dutch pair Jacco Eltingh and
Paul Haarhuis 6-2, 5-7, 18-16 in 1996.
Earlier in the day Hewitt beat veteran Swede Jonas Bjorkman
7-5, 7-6 in the first round of the men's singles.
Ivanovic withdrew from the tournament Sunday because of a thumb injury.
It was a good day for the Chinese women. Li Na delighted the center-court crowd by upsetting No. 3-seeded Svetlana Kuznetsova of Russia 7-6 (5), 6-4. Also advancing were Zheng Jie, a semifinalist this year at Wimbledon, and Peng Shuai.
Nicolas Massu of Chile opened his bid to repeat as Olympic champion by beating Steve Darcis of Belgium 6-4, 7-5. But Massu and Fernando Gonzalez, who won the gold medal in doubles at Athens, were beaten by Tursunov and Mikhail Youzhny 7-6 (5), 6-4.
With his early start, Nadal at times appeared to need a wake-up call. He struggled on the backhand side, and shook his head or rolled his eyes when usually reliable strokes misfired. Because of Beijing's oppressive humidity, Nadal said, he was changing his shirt every 10 minutes.
A highlight-reel rally got him going in the third set. Nadal sprinted into the alley near the net in pursuit of a ball and scooped a forehand winner cross-court as he braked to avoid running into the post, then fell to his back. He rose and threw a jubilant fist, leaving behind a splotch of sweat on the concrete.
After failing to convert seven consecutive break-point chances in the second and third sets, he broke for a 4-2 lead in the final set. He erased a 15-40 deficit on his serve in the next game, then broke again for the victory.
"I had a lot of opportunities. I didn't convert, so that was tough," Nadal said. "But I was winning the serves without problems. He had more problems than me when he was serving, so that gave me confidence."
Seeded second, Nadal is on a roll after beating Federer in the finals at the French Open and Wimbledon. The latter result compounded Federer's yearlong slump, and regardless of the outcome at Beijing, he'll be supplanted atop the rankings by Nadal next week.
"It's just a matter of losing some matches where I feel like I shouldn't have lost," Federer said. "And then sometimes it plays a trick in your mind where you think maybe you're not playing that well actually, but it's actually not the case. So it's a matter of keeping yourself in a positive mindset."
Federer has won only two tournaments in 2008, and an Olympic gold medal would help him salvage the year after he was shut out of the medal chase at Sydney in 2000 and at Athens in 2004.
Information from The Associated Press and Reuters was used this report.