Top seed Federer made many uncharacteristic, unforced errors before stepping up a gear to move past his 18-year-old opponent from Serbia & Montenegro.
The elegant Swiss looked in control in the first set but struggled in the second, dropping serve twice before losing the set by firing a straightforward forehand wide.
Djokovic, though, ran out of steam in the next set and began giving away points.
Federer, playing aggressively at last, broke his unheralded opponent straight away in the decisive set.
Djokovic went down fighting, saving three match points before hitting a forehand long on the fourth.
"I'm satisfied to have won and relieved it's over," said Federer.
"It was not easy. I didn't play great but you need time to adapt to the surface."
The 24-year-old Federer is chasing his third successive Masters Series title of the year after winning the first two rounds in Indian Wells and Miami.
REAL TEST
The Swiss, who was stunned by Frenchman Richard Gasquet in the quarter-finals here last year, is beginning his preparations for the only grand slam tournament to elude him, the claycourt French Open starting on May 28.
"Many people say I'm better on other surfaces but I know I can play well on clay," Federer said. "The French Open is definitely a goal of mine."
Federer goes on to meet Spaniard Alberto Martin who beat Croatian Ivo Karlovic 6-4, 7-6.
"It'll be a real test against a claycourt specialist," Federer said of his next match. "It's good to have such a test so early in the claycourt season. I'll know straight away where I stand."
Argentine David Nalbandian, seeded third, advanced easily, beating Belgium's Xavier Malisse 6-4, 6-4.
Finn Jarkko Nieminen, the 14th seed, became the first seeded player to bow out when Belgian Kristof Vliegen beat him 1-6, 6-4, 7-6.
Briton Tim Henman, a surprise semi-finalist at the French Open two years ago, followed Nieminen out when Argentine baseliner Gaston Gaudio brushed him aside 6-1, 6-3.
Federer's most serious rival, world number two Rafael Nadal of Spain, who won here last year, will enter the tournament on Tuesday against Frenchman Arnaud Clement.
(Writing by Patrick Vignal in Paris)