The 20-time Grand Slam champion needed just 52 minutes to brush Gasquet aside in the second round, but confessed he had to control his emotions during afternoon match strategy sessions with his team.
"I was very calm all day, but two hours before, I was feeling it a bit. But that was the only time," Federer said.
"The nerves went away quickly, I'm just happy I started well.
Federer skipped the dirt for two full seasons to concentrate on his grass court form, winning Wimbledon in 2017.
He claimed the Madrid title in 2006, 2009, and 2012.
"I've been missing the clay, this is a great return, it's a special night for me," he said.
Federer swept up the opening set in 23 minutes and broke Frenchman Gasquet -- who had defeated him twice on clay -- for 5-3 in the second before serving it out a game later.
Federer has won 18 of 21 meetings with Gasquet, just back from six months out with injury.
"I've trained well, but that's not like a match. The points here are quicker and first matches anywhere can be tricky," said Federer.
"But I felt really natural on the clay tonight."
- Djokovic cruises -
Novak Djokovic needed just 65 minutes to make a winning start, while Naomi Osaka channelled her inner "zombie mode" to earn a place in the third round.
Top seed and world number one Djokovic hammered American Taylor Fritz 6-4, 6-2 to advance to the last 16 following a premature exit here a year ago.
"I thought my serve was very efficient today, that's a big advantage," Djokovic said.
"The match was close at the beginning, in the second set I read his serve better and just managed to put an extra ball in to the court.
"It was a solid opening match for me."
Djokovic won the Madrid title in 2011 and 2016. He will be chasing a fourth straight Grand Slam trophy at Roland Garros next month.
David Ferrer, who will retire after this event, defeated Spanish compatriot Roberto Bautista Agut 6-4, 4-6, 6-4.
Ferrer, 37, will play German third seed and defending champion Alexander Zverev next.
The Swiss will next play Argentine Guido Pella, who put out Barcelona finalist Daniil Medvedev 6-2, 1-6, 6-3.
- 'Zombie mode' -
In the women's draw, top seed Osaka defeated Spain's Sara Sorribes Tormo 7-6 (7/5), 3-6, 6-0.
Japan's Osaka, winner of the last two Grand Slams, said she had to conquer her inner demons to finish off a difficult match.
"In the third set, I just, like, went zombie mode," she said.
"I just thought of everything that I had to do to win -- not necessarily the outcome, but just like the little things in between every game.
"The match was basically on my racquet, she wasn't going for winners.
"The points ended by me making a winner or an unforced error. But I was a bit unfocused in the second set." Third seed and two-time champion Simona Halep of Romania ended the hopes of Johanna Konta 7-5, 6-1 in the second round.
"I feel good every time when I come to Madrid and I'm happy to be back and winning matches," Halep said.
"It was a good match. Both of us played very well and, in the end, I was a bit stronger mentally and I found a rhythm." Fourth seed Angelique Kerber withdrew after rolling her right ankle during training, sending Petra Martic into the third round.