The third seed was blown away by Cilic's serve the last time the two met at the US Open in 2014, but he had the chance to make a crucial break in the fifth game of the opening set against the big-hitting Croat.
However, Cilic saved two break points before holding, and with Federer also faultless on his own serve the first set went all the way to a tie-break.
Cilic quickly raced into a 5-0 lead in the breaker and, although Federer fought back, the damage had been done and Cilic eventually wrapped it up with his third set point.
Before the match Federer admitted to being relieved by Novak Djokovic's early exit from the competition, but he soon appeared to be on course for the same fate when he was broken in the third game of the second set.
Cilic saved a break point in the next game to stay in control, and he lost just two more points on his own serve throughout the set to take it 6-4.
The 17-time Grand Slam champion was in even more trouble when he found himself 0-40 down in the seventh game of the third set, but he saved three break points to prevent Cilic from serving for the match and went on to break the Croat for the first time in the very next game.
That was enough for him to go on and win the set 6-3 and stay in the match, but Cilic would not lie down and more than held his own once again in the fourth set.
Indeed, the ninth seed had two match points on Federer's serve, but the Swiss saved both of them to force a tie-break.
The breaker proved to be every bit as closely contested as the rest of the contest, with Federer squandering four break points and Cilic also having a chance to wrap up the match before the former finally won 11-9 to force a decider.
Cilic reached deuce in the opening game of the final set, but Federer ended up taking the lead in the match, knifing a sliced backhand into the turf to draw a backhand error from Cilic.
Both players continued to serve up emphatic tennis in a bid to clinch the match, but it was the experienced Federer who edged into the lead before closing proceedings with a triumphant ace to remain in the hunt for a record eighth Wimbledon crown.