WATCH the ATP Tour LIVE on beIN SPORTS | available via Foxtel, Kayo Sports, Fetch TV & beIN SPORTS CONNECT
The 39-year-old was playing his first competitive match in 14 months, having undergone knee surgery since his last appearance at the 2020 Australian Open.
Evans and Federer have practiced together over recent weeks and combined to produce a high-quality affair in Doha, with the veteran showing phenomenal staying power after so long away to book a quarter-final meeting with Nikoloz Basilashvili.
The only break point of the opening set came in the ninth game, with Federer holding and coming through two deuces.
World number 28 Evans boomed down a pair of aces and held to love after that minor setback and reeled off four consecutive points to lead 4-2 in the breaker.
Federer saved one set point and converted his third with a wonderful backhand passing shot.
A battle that eventually lasted two hours and 26 minutes appeared unlikely as Federer sought to press home his superiority, Evans coming into the net to repel a break point in the opening game of set two.
But the Briton was the first man to make a dent on the other's serve, with Federer unusually ragged as he pulled a forehand then a backhand wide from deuce to go 1-3 behind.
The Swiss could not capitalise on a break-back point in the next game and, having been taken to deuce in all previous games in the set, Evans produced back-to-back aces and held to love to square the match.
Federer's first-serve percentage fell from an imperious 83 to 58 between sets one and two and he looked tired when slipping to 0-30 at 2-2 in the decider before recovering to hold.
Evans, who also went the distance against Jeremy Chardy on Sunday, was similarly robust under pressure – a serve-volley and his formidable backhand slice seeing him through a match-point game at 4-5 – but he could not keep the insatiable Federer at bay as a majestic backhand down the line settled the argument.