The Spanish left-hander, who has reached the semi-finals at Indian Wells in his last six appearances here, broke Mayer twice in each set to wrap up a commanding win in one hour 15 minutes.
In dazzling afternoon sunshine, the match ended when a Mayer forehand sailed wide and Nadal removed his green headband in triumph as the near-capacity crowd erupted in applause.
"It's nice to be back playing at the very good level," the Spaniard, who will next face compatriot Marcel Granollers, told reporters at the Indian Wells Tennis Garden. "Winning is the most important thing.
"It's not easy to be back after a while without competition, but I did really well. I started the match very focused, very aggressive. I'm very happy about almost everything."
Nadal, who dominated Mayer with his crunching ground strokes from behind the baseline, had not competed since he lost an epic Australian Open final to Novak Djokovic in January.
The world number two enjoys a superb record at Indian Wells where he won the title in 2007 and 2009 and was beaten in last year's final by Serb Djokovic.
"This is a tournament that I love," said the 25-year-old from Mallorca. "I enjoy a lot playing this tournament. Always in my career I've had good success here. I have played very good matches.
Granollers had earlier booked his place in the third round with a 6-3 2-6 6-3 win against Germany's Tommy Haas.
The big-serving Tsonga will next face Czech Radek Stepanek, who crushed Belgium's Xavier Malisse 6-2 6-1.