The legendary Swiss is going for a third consecutive title in Melbourne, but he was made to work hard by Evans in two hours and 35 minutes of action on Rod Laver Arena.
Caroline Wozniacki, the defending champion in the women's singles, had an easier time of things as she eased past Sweden's Johanna Larsson in 66 minutes.
Rafael Nadal also made quick work of his second-round match against Australia's Matthew Ebden, winning 6-3, 6-2, 6-2 in one hour and 56 minutes.
The biggest shock of the day saw men's fifth seed Kevin Anderson beaten by 20-year-old American Frances Tiafoe.
Selected Wednesday Results
(3) Roger Federer bt. Dan Evans: 7-6 (5), 7-6 (3), 6-3
Frances Tiafoe bt. (5) Kevin Anderson: 4-6, 6-4, 6-4, 7-5
(6) Marin Cilic bt. Mackenzie McDonald: 7-5, 6-7 (9), 6-4, 6-4
Andreas Seppi bt. Jordan Thompson: 6-3, 6-4, 6-4
Taylor Fritz bt. (30) Gael Monfils: 6-3, 6-7 (8), 7-6 (6), 7-6 (5)
(2) Rafael Nadal bt. Matthew Ebden: 6-3, 6-2, 6-2
(5) Sloane Stephens bt. Timea Babos: 6-3, 6-1
(15) Ashleigh Barty bt. Yafan Wang: 6-2, 6-3
Anastasia Pavlyuchenkova bt. (9) Kiki Bertens: 3-6, 6-3, 6-3
(3) Caroline Wozniacki bt. Johanna Larsson: 6-1, 6-3
(11) Aryna Sabalenka bt. Katie Boulter: 6-3, 6-4
(2) Angelique Kerber bt. Beatriz Haddad Maia: 6-2, 6-3
(30) Maria Sharapova bt. Rebecca Peterson: 6-2, 6-1
Full results can be found at the Australian Open's official website.
Briton Evans is ranked No. 189 in the world, but despite not getting a set on the board against the third seed, he came away from the clash with enormous credit.
Federer failed to earn a break point until the 12th game of the first set, and Evans was confident enough to serve-and-volley in order to force a tiebreak.
In the breaker, it was the underdog who went into a 5-3 lead, but Federer upped his game in typical style at the crucial moment to eventually come out on top:
When the 20-time Grand Slam winner—who is going for an unprecedented seventh Australian Open title—broke Evans in the first game of the second set, it looked as though the contest may be over.
But Evans composed himself to trade subsequent holds with Federer, and then remarkably set up another tiebreak when he claimed a break of his own for 5-5, taking full advantage of a double-fault from the Swiss and producing a fine backhand winner.
In the second breaker of the match, though, Federer went into a 3-0 lead from which Evans could not recover, and the third set unfolded in a more predictable manner as the defending champion sealed victory.
The 37-year-old will now face Taylor Fritz in the third round after the 21-year-old American overcame Gael Monfils in a 204-minute epic on Wednesday.
Nadal, meanwhile, put on a show against Ebden in front of a raucous crowd.
Ebden understandably had the backing of most of Rod Laver Arena, and he gave them numerous moments to cheer against the No. 2 seed.
But Nadal never looked uncomfortable, breaking five times in the match and saving all four of the break points Ebden managed to carve out.
The Spaniard pulled out numerous vintage forehand winners as he eased to victory, one of which finished the match off:
World No. 3 Wozniacki won her first Grand Slam in Melbourne last year and continued the defence of her title with a clinical display against Larsson.
The Danish star served at 76 per cent during the clash and impressively won 92 per cent of points behind her second serve.
Two breaks of serve in each set saw Wozniacki to victory without really having to get out of third gear, and she will now face Maria Sharapova in a mouth-watering third-round tie.
The United States' Sloane Stephens was similarly efficient in earning her second win of the tournament against Hungary's Timea Babos.
The world No. 5 took full advantage of her opponent's 44 unforced errors as she hit 15 winners in the 95-minute contest.
Stephens had not made it past the first round at the Australian Open since 2014, and she will now be looking to at least match her 2013 campaign in Melbourne when she made the semi-finals.