Federer had won his last eight meetings against Gasquet, but his uncharacteristic errors from the baseline allowed the 16th-seeded Frenchman to take control.
"I definitely feel I should never have lost this match," Federer said. "I just couldn't come up with the shots."
Djokovic has won all 34 of his matches this year, trailing only John McEnroe's 42-0 start in 1984 in the Open era. The Serb can claim the top ranking from Rafael Nadal if he wins this tournament and Nadal fails to reach the semifinals.
Earlier, Nadal overcame a virus to beat fellow Spaniard Feliciano Lopez 6-4, 6-2. The start of the match was delayed by about 20 minutes because Nadal considered withdrawing.
"I had a fever last night and this morning I didn't feel better," Nadal said. "I didn't know if I was going to go on the court for the match. I decided at the last moment."
In his opening match Wednesday, Nadal struggled past 148th-ranked qualifier Paolo Lorenzi in three sets.
"I didn't understand why I felt so slow yesterday, why I had no energy. I understand today," Nadal said.
To keep his No. 1 ranking for at least one more week, Nadal will need to beat Marin Cilic of Croatia in the quarterfinals.
This tournament is a key warm-up event for the French Open, which starts in 10 days, and it is one of only three Masters Series events the Swiss star has never won. He didn't seem to think the loss would affect his game at Roland Garros.
"I'll definitely be happy to take two, three, four days off to get mentally fresh and then practice very hard," he said. "There's no reason to panic."
Federer seemed on his way to advancing when he won 10 straight points to open the match. But the 16-time Grand Slam winner squandered a 4-2 lead in the second set, then failed to convert two break points that would have given him a chance to serve out the match.
Federer missed several backhands in the second-set tiebreak and floated another backhand long on Gasquet's first match point in the deciding breaker. In all, Federer committed 30 unforced errors to Gasquet's 19.
"I had multiple chances," Federer said. "It's disappointing. ... I probably never felt I was going to win the breaker -- it's tough to play that way."
The match was delayed for about 10 minutes early in the second set when water mysteriously began leaking onto the corner of the court.
Schiavone is ranked a career-high fourth but is seeded higher this week since No. 2 Kim Clijsters is injured and No. 3 Vera Zvonareva didn't enter. With Serena and Venus Williams also injured, local fans are hoping Schiavone can become the first Italian to win this tournament since Raffaella Reggi in 1985.
After Schiavone chased down a drop shot and landed a winner up the line to secure the victory, organizers blasted an old Neapolitan folk song over the loudspeakers and nearly all in the crowd of 10,500 sang along.
"They key against [Stosur] is always the same, you've got to stay inside the court and take control," Schiavone said. "Whoever takes the initiative wins. I've beaten her both in Paris and in Fed Cup, but the matches have always been very balanced."
Top-ranked Caroline Wozniacki eliminated Yanina Wickmayer 6-1, 7-6 (4) and will next meet two-time Rome champion Jelena Jankovic, a 6-4, 2-6, 6-2 winner over Spanish qualifier Anabel Medina Garrigues.