Federer was below par by his lofty standards
Roger Federer came back from the brink of another shock defeat to beat Robby Ginepri at the Cincinnati Masters.
American Ginepri took the first set 7-6 and was serving for the match at 6-5 in the second as he played some inspired tennis against his Swiss rival.
But Ginepri buckled with a win in sight as Federer levelled after a tie-break.
A stomach injury then badly affected Ginepri, and Federer, who suffered a shock defeat by Gilles Simon in Toronto, won the deciding set 6-0.
Federer was not at his best but will be relieved to avoid defeat which would have put his world number one status at further threat from Rafael Nadal.
The Spaniard is just 300 points behind Federer in the rankings and could end his reign of 235 weeks at the top of the standings this week.
"I enjoy the challenge of being number one in the world," Federer said. "I like that. I would rather be me than him [Nadal].
"I have had a great run so far, and although I have been disappointed that my hard work has not paid off with a Grand Slam win, I am over it now."
Federer broke Ginepri in the seventh and ninth games of the first set but his opponent hit back each time to level at 5-5 before a tie-break.
Ginepri won the tie-break 7-2 and got a crucial break of serve in the 11th game of the second set before Federer recovered and went on to win.
In another second-round match, Swede Robin Soderling beat 12th seed Tommy Robredo of Spain 7-6 (8/6) 6-4.
France's Richard Gasquet, seeded 11, came through his first-round encounter when countryman Michael Llodra retired with an arm injury with the score at 3-6 6-1 1-0.
But Andy Roddick has been forced to withdraw from the tournament after suffering a neck/shoulder injury while asleep in bed.
"I fell asleep last night and woke up with the lights still on," the world number six said on Tuesday. "I kind of passed out and and I'm guessing I was in the wrong position.
"I woke up this morning with something in my neck and shoulder and any kind of activity is causing it to flare up. It's kind of a helpless feeling."
Roddick had already decided to miss the Olympics but hopes to compete in tournaments in Los Angeles and Washington in the next few weeks before the US Open begins in New York on 25 August.