Roger Federer survived a scare against the unseeded Filip Krajinovic to extend his winning run at the Swiss Indoors Basel to 16 matches.

World number three Federer began his bid for a ninth title in his hometown with a hard-fought 6-2 4-6 6-4 first-round triumph over the Serbian.

The Swiss coasted through the first set but was broken three times as Krajinovic forced a decider, where the top seed required two chances to serve out the match.

Federer won his only previous meeting with Krajinovic at the Indian Wells Masters this year in straight sets and he looked on course for a repeat following a searing start.

The 37-year-old responded to dropping his serve twice in succession in the second set by breaking Krajinovic to love but, after saving a set point with an ace, he sent a forehand into the net to send the match the distance.

Federer came under continued pressure and despite failing to serve out the set after coming through an 11-minute game with a break of serve, a long backhand from Krajinovic sent him into a second-round meeting with Jan-Lennard Struff.