Mayer defeated Marius Copil 6-3, 6-7 (3), 7-5 in the first round on Monday. The 63rd-ranked Argentine saved all five break points he faced in a match lasting more than two and a half hours.
Second-ranked Nadal, an 11-time winner in Barcelona, opens play at the clay-court tournament on Wednesday after a first-round bye. He is coming off a loss to Fabio Fognini in the semifinals of the Monte Carlo Masters.
"My personal opinion is that I played one of the worst matches on clay," Nadal said in Barcelona. "It's a reality. There is no need to hide it. What has happened has happened."
Fognini, the champion in Monte Carlo, will play either Nicola Kuhn or Federico Delbonis, who meet on Tuesday.
Argentine Diego Schwartzman, who had to go through qualifying after missing the deadline to enter the main draw, defeated Japanese Yoshihito Nishioka 4-6, 6-4, 6-2. He will play third-seeded Dominic Thiem of Austria on Tuesday.
In other results on Monday, Fernando Verdasco defeated wild card Feliciano Lopez 6-4, 6-3 in an all-Spanish match, Mackenzie McDonald of the U.S. beat Taro Daniel of Japan 6-2, 6-2, and Taylor Fritz got past Reilly Opelka 6-3, 6-4 in a meeting of Americans.