(CNN) — The old met the new. At one end of the court, the young man nicknamed "Baby Federer" at the other was one of the all-time tennis greats, albeit one who is battling to show that he's not a spent force.
One of them has 77 career titles, but only one this year, while the other a former top-ranked junior won his first on the ATP Tour last weekend.
And after losing the first two games, despite a vociferous home backing, it certainly looked like Roger Federer might be headed for another disappointing defeat.
But the Swiss legend battled back to show why he is the holder of a record 17 grand slam titles as he denied Grigor Dimitrov 10 years younger at 22 a famous victory in Basel.
Federer, now ranked a comparatively lowly sixth by his high standards, eventually triumphed 6-3 7-6 (7-2) against the Bulgarian as he also came from behind in the second set to force the tie-break.
"It was very important to win in two sets," said Federer, who notched his 50th win in his home city event a feat he had previously managed only in the four majors.
"There were a lot of free gifts out there in some games. When I saved three set points I just told myself to play one point at a time and hope to get there.
"I broke him and that made it difficult for him. I was able to come through well in the tiebreaker. It always feels good to win at home."
If Federer can next beat Canada's Vasek Pospisil in the semifinals of the Swiss Indoor s event and then win it for a record-extending sixth time, he will qualify for the ATP World Tour Finals in London with one tournament to spare next week's Paris Masters.
That there has been doubt Federer might not participate in next month's season-ender a tournament he has won six times since 2003 is a measure of how much he has struggled this year.
If 2012 was his return to the top, a year in which he won Wimbledon a record-equaling seventh time, regained the No. 1 ranking and broke the milestone for most weeks at the summit, then 2013 has been a major comedown.
After reaching the semifinals at January's Australian Open, he lost in the quarters at Roland Garros, the second round at Wimbledon and in the last 16 in New York.
Injuries and experiments with new rackets have taken the edge off his once invincible aura, giving players like Dimitrov real hope that they can claim a never-to-be-forgotten scalp.
But not this time. Federer will next face a 23-year-old ranked 40th in the world, with a 17-16 record this year.
But Pospisil is showing a return to the form that helped him beat world No. 6 Tomas Berdych in Montreal in August, reaching his third ATP Tour semifinal this season with a 7-6 (11-9) 6-4 win over Croatia's Ivan Dodig.
Saturday's other semi will be between defending champion Juan Martin del Potro, who beat Federer in last year's final, and Frenchman Edouard Roger-Vasselin.
Del Potro, who has already qualified for one of the eight places in London, became just the sixth Argentine to register 300 career wins as he defeated qualifier Henri-Paul Mathieu 6-4 6-4.
The world No. 5, who now has a record of 300-120, is seeking his fourth title this year.
Meanwhile, world No. 3 David Ferrer continued the defense of his Valencia Open title by reaching the semifinals with a 6-4 4-6 6-0 win over Polish fifth seed Jerzy Janowicz.
The Spaniard will next play compatriot Nicolas Almagro, while Russians Mikhail Youzhny and Dmitry Tursunov will contest the other semi.