Federer will play Jo-Wilfried Tsonga in the third round in Madrid
Roger Federer moved safely into round three of the Madrid Masters with a 6-2 7-6 (8-6) victory over Radek Stepanek.
The world number two rallied from 5-3 down in the second set tie-break to win on his return from a five-week break.
"I'm happy to be back on tour," said the Swiss. "It was always going to be tough against Radek and he played a great second set."
Elsewhere, American qualifier Robby Ginepri battled to a surprise 4-6 6-4 6-4 victory over Nikolay Davydenko.
The fifth-seeded Russian started well, converting one of three break chances to comfortably take the first set.
But while Davydenko hit 35 winners to Ginepri's 15, he committed 53 unforced errors as he lost the final two sets.
Australian Open champion Novak Djokovic advanced after the impressive Victor Hanescu retired hurt in the third set.
Hanescu took the first set on a tie-break before Serb Djokovic did the same in the second.
But the Romanian, who had pushed the world number three hard in the second set, retired because of injury when 6-7 (8-10) 7-6 (10-8) 3-1 down with what appeared to be a groin injury.
"It's a big relief to win, this is a big boost up for upcoming matches," said Djokovic. "He used his biggest weapon which was his serve. I couldn't find any rhythm in return, so he used that wisely."
Djokovic will now face Ivo Karlovic in the third round after the tall Croatian beat Sweden's Robin Soderling 7-6 7-6.
Federer will meet Australian Open finalist Jo-Wilfried Tsonga in the third round after he beat Spain's Marcel Granollers 3-6 6-3 7-6 (7-2).
Andy Roddick had little trouble getting past Spain's Tommy Robredo 6-3 6-4, while Argentine Juan Martin del Potro advanced after Jarkko Nieminen of Finland retired when trailing 6-2 4-2.
Feliciano Lopez took in an all-Spanish tie as he beat sixth seed David Ferrer 6-4 7-6 (7-4), while defending champion David Nalbandian beat Tomas Berdych 6-2 6-7 (5-7) 6-1, and France's Gael Monfils beat Chile's Fernando Gonzalez 6-3 6-4.