The 20-time Grand Slam title winner, who underwent two knee surgeries in 2020, secured the first set but eventually wilted and lost the quarter-final tie, 3-6, 6-1, 7-5.
On Wednesday, the 39-year-old marked his first match since losing to Novak Djokovic in the Australian Open semi-finals in January 2020 by defeating Britain's Dan Evans, also in three sets.
"He's one of the greatest tennis players of all time," said world number 42 Basilashvili who will face Taylor Fritz of the United States for a place in the final.
"I'm very happy that he's coming back and playing again. Of course to win against him it's a dream come true. He was an idol."
Basilashvili, who arrived at the Qatar ExxonMobil Open with a 2-13 record since the resumption of the sport in August, managed two aces in a row in the second set, clearly unsettling the Swiss three-time Doha champion.
In the third set, Federer dug deep to clinch an epic seventh game, coming back from three break points to keep the contest alive.
But after saving a match point, the 29-year-old Basilashvili broke Federer's serve to go up 6-5, before serving out for a famous win.
Spain's Roberto Bautista Agut stunned Austrian top seed and US Open champion Dominic Thiem 7-6 (7/3), 2-6, 6-4.
He will next face Russia's Andrey Rublev who made the last-four without hitting a ball.
Third seed Rublev had a first round bye which was followed by injury-enforced walkovers handed to him by Richard Gasquet and Marton Fucsovics who withdrew Thursday complaining of lower back pain.