Rafael Nadal beat Canadian teenager Felix Auger Aliassime 6-3 6-3 to reach the Madrid Open third round.
The 32-year-old world number two, who has been struggling with a virus, won the first break point of the match in the eighth game before taking a tight first set.
Aliassime, 18, saved five match points on his own serve in the second set but Nadal won the sixth to seal victory.
Nadal, seeking his sixth Madrid title, will play American Frances Tiafoe next.
The Spaniard has yet to win a title this season and went into the tournament on the back of semi-final defeats in Barcelona and Monte Carlo.
"I've had a tough few days with a stomach virus so the main thing was the victory," said Nadal, who had a bye into the second round.
"Felix is a great opponent; he will be a great champion. It was a tough first round so I'm very happy to go through."
Spaniard David Ferrer brought a close to his 19-year career as a professional as he bowed out at the second-round stage with a 6-4 6-1 defeat by third seed Alexander Zverev.
The 37-year-old shared a warm moment with the German at the end of the match before addressing the crowd inside the Manolo Santana court.
In the men's doubles, Britain's Jamie Murray and Brazilian partner Bruno Soares moved into the quarter-finals with a 7-6 (7-5) 6-2 win against Argentina's Juan Martin del Potro and Japan's Kei Nishikori.
However, the other British men's pair of Kyle Edmund and Neal Skupski went down 6-2 6-7 (4-7) 10-5 to Dutchman Jean-Julien Rojer and Romania's Horia Tecau in their second-round match.