The Swiss lost five games in a row as he dropped the fourth set but recovered to win 6-2 6-7 (5-7) 6-3 3-6 6-1.
Federer, 36, becomes only the fourth player after Margaret Court, Serena Williams and Steffi Graf to win 20 or more major singles titles, the BBC reports.
"It's a dream come true and the fairytale continues," said Federer, who has won three of the last five majors.
The final was played under the Rod Laver Arena roof as the tournament's extreme heat policy was invoked.
Despite starting at 19:30 local time in Melbourne, the conditions were if anything more testing than 24 hours earlier, when Caroline Wozniacki and Simona Halep played to the point of exhaustion in the women's final.
With the roof closed and air-conditioning taking the edge off the temperature, Federer and Cilic played out a gripping contest over three hours and two minutes.
After a poor start, Cilic looked to have the momentum when he won five games in a row to force a fifth set, but Federer clung on to his serve at the start of the decider and got the key break in the following game.
The Swiss ties the record for men's Australian Open titles at six with Novak Djokovic and Roy Emerson, and moves four clear of Rafael Nadal in the all-time list for male Grand Slam champions on 20.
"I'm so happy, it's unbelievable," Federer added. "After the year I had last year, it's incredible."
Cilic, 29, had come into the final brimming with positivity after an impressive run to the final that included a quarter-final win over Nadal, but he made a desperate start.
He won just four points in losing the opening four games, and Federer fired down back-to-back aces on his way to serving out the set after 25 minutes.
The Swiss saw off two break points early in the second, roaring "come on!" as he pulled a forehand winner down the line, and then resumed his assault on the Cilic serve.
Three break points were saved, the third with a second-serve ace, as Cilic edged his way into a tie-break and a chance to claw his way back into the match.
The 2014 US Open champion did just that after a huge cross-court forehand brought up two set points, and he smashed away the second to level.
Federer appeared to have regained control when a deep return drew an error as he broke for 4-2 in the third, and a fabulous half-volley pick-up said the confidence was flowing as he moved ahead again.
With a point for a double-break early in the fourth, Federer appeared as good as home, but his first-serve began to falter and Cilic ripped into the second serve with his huge forehand.
After two hours and 10 minutes he finally broke the Federer serve, and a jolt of adrenaline coursed through the Croat - and the crowd - as this unexpected fightback took him to two sets all.
Federer was now struggling to contain the world number six, and was relieved to see a return hit the net on break point at the start of the fifth, before roaring as a serve saw off a second chance for the Croat.
The Swiss had halted the momentum and in the next game he grabbed it for himself with a deep, fizzing return that Cilic could not handle.
Nerves were still apparent as the eight-time Wimbledon champion urged himself on during the changeover, but he was not about to let his opponent back in, and another break of serve all but made sure.
There was time for one more moment of uncertainty for Federer when, just as in last year's final, he was forced to wait on match point for Hawk-Eye to confirm that he had indeed retained the title.