(CNN) -- Roger Federer came perilously close to defeat in his opening match at Wimbledon against world number 60 Alejandro Falla of Colombia before carving out a five-set victory on Centre Court on Monday.
Falla led the six-time champion by two sets and served for the match at 5-4 in the fourth set before the top seed hit back to win 5-7 4-6 6-4 7-6 6-0 in just under three and a half hours.
Federer admitted that he had been very fortunate to avoid going out against an inspired opponent.
"I definitely got very lucky out there today," he told BBC Sport. "This was one I should have lost.
"I haven't been two sets to love down in the opening rounds of a grand slam and it came as a bit of a shock, it's something I was not prepared for.
"But you draw from your experience and it pushes you through and I live for another day," added a relieved Federer.
The 28-year-old has not won a tournament since claiming the Australian Open title in January, but looked in fine fettle at the start of the match, putting his opponent under pressure on his own service.
But at 5-5, Falla created two break points on Federer's delivery and took the second before serving out to take the opener.
Still there looked no need for panic, with Federer having beaten Falla at their two previous tournaments, the latest win in Halle where the underdog had claimed just three games.
But the alarm bells started to ring when Falla broke him in the sixth game of the second set as Federer hit a weak forehand into the net on break point down.
The Swiss star bravely saved three set points in the 10th game, but Falla closed it out on the fourth to go two sets up.
Falla received treatment for a groin injury, but it appeared to trouble him little and in the third set there was a moment of extreme danger for the world number two as he fell three break points down on his own service at 4-4.
Digging deep, Federer saved them all, then a fourth in brilliant exchanges as he clung on to his title by his fingertips.
The roles were reversed in the next game as a seemingly revived Federer took advantage of his second set point.
But it proved a false dawn as Falla broke at the start of the fourth set to put more pressure on Federer.
Aside saving a break point in the eighth game, Falla held on to his service comfortably enough until serving for the match at 5-4 as he fell 0-30 and then two break points down before Federer leveled at 5-5.
Federer faced another break point in the next game, but retrieved it before winning the game with an exquisite drop shot.
Falla pulled level to force a tiebreak, but Federer was now in command and took it seven points to one.
The decider was a formality as the Swiss maestro broke his brave opponent at will and did not drop a further game as he went into the second round.
Elsewhere in the men's draw, seventh seed Nikolay Davydenko survived a major scare before advancing to the second round.
The Russian had to come from two sets behind to beat South Africa's Kevin Anderson 3-6 6-7 7-6 7-5 9-7.
Third seed Novak Djokovic also needed five sets to get past Olivier Rochus of Belgium in a match which finished at 11pm local time under the Centre Court roof.
The Serb went two sets to one down but eventually prevailed 4-6 6-2 3-6 6-4 6-2.
Fifth seed Andy Roddick trounced fellow American Rajeev Ram 6-3 6-2 6-2 to reach the second round.
Former champion Lleyton Hewitt, who beat Federer in the Gerry Weber Open final earlier this month, had to come from a set behind to overcome Argentina's Maximo Gonzalez.
The biggest upset of the day saw 11th seeded Croatian Marin Cilic lose in straight sets to Germany's Florian Mayer.