Britain's world number 189 slowed the Fed Express to a crawl, keeping the Swiss master battling for more than two hours to win the opening two sets before finally succumbing 7-6 (7/5), 7-6 (7/3), 6-3.
The 20-time Grand Slam champion, who is gunning for a record seventh Melbourne Park title and third in a row, admitted he had been given an unusual challenge by the 28-year-old, who plays a similar style of tennis.
“Playing a player like Dan Evans is like facing myself,” the 37-year-old Federer said.
“It feels like playing a mirror a little bit. That was my mindset heading into it — how would I play myself potentially?”
Evans, whose ranking plummeted from a career-high 41 after he was slapped with a year-long ban for testing positive to cocaine in April 2017, played almost flawless tennis to stave off a set point on his way to forcing a first set tie-break.
He even had the temerity to lead 5-3 in the breaker before Federer stepped up a gear and reeled off the next four points to secure the set with a cry of “Come on!”.
“It always helps when you sneak a break in the first set,” said the Swiss star after a ding-dong contest lasting 2hr 35min. “The match might have been different.”
Federer said he had expected Evans to cause him more problems than when he cruised through their previous Grand Slam meeting at Wimbledon in 2016 for the loss of just eight games.
“I have high regard, you know, in Dan. I think he's a good player. I've seen him play some really good matches over the years, I see why he can cause difficulties,” he said.
“He's got a nice slice, defending the court well. He has the variation, which is always a hard thing to play against.
'Cat and mouse'
“He was very sort of cat and mouse. I liked the match. It was enjoyable.”
The loss of the first set after exactly an hour was harsh on Evans who had committed only two unforced errors and constantly put the third seed under pressure with his scampering, attacking game and flurry of winners off both wings.
The plucky Evans, who had covered acres of ground and found the lines unerringly, needed treatment for blisters on both feet before the second set started and immediately was broken.
But he refused to lie down and broke back as Federer served for the set to force another tie-break.
“I thought I might have pulled away midway through the second set,” added Federer. “But I couldn't, to his credit. He played well.”
The Swiss great hasn't often needed luck during his unparalleled career but he took advantage of some in the third set to finally ease the pressure.
Holding break point at 2-1, he barely scooped up a half-volley which grabbed the net cord and toppled over forcing Evans to go long.
A service game to love followed to put Federer 4-1 up and the brave resistance of Evans was finally broken.
The veteran will play unseeded American Taylor Fritz in the last 32.