The Swiss veteran lost five games in a row as he dropped the fourth set but recovered to win 6-2 6-7(5) 6-3 3-6 6-1 under the Rod Laver Arena roof.
The match, played with the roof closed and air conditioning due to the extreme heat, began with Federer firing on all cylinders as he sealed the first set in just 24 minutes.
Cilic was a different proposition in the second set, however, taking his opponent to a tie-break before settling it with a composed overhead smash.
Federer was back to his ruthless best in the third set as he dominated proceedings once again and edged back into the advantage with an ace.
The Croatian sixth seed, however, prevailed in the following set to ensure that the match would go the whole distance.
Federer clung on to his serve at the start of the decider and got the key break in the following game to see the set and the match out with ease.