The Swiss, who skipped the entire European claycourt swing to concentrate on the grasscourt season, showed signs of rust early on against Zverev but it did not take too long for him to rediscover his rhythm.
Federer had some early chances but could not take them and it was Zverev who struck first when he broke to love to lead 5-3 before a couple of aces helped him pocket the opening set.
It was the first set Zverev, older brother of world number three Alexander, had ever taken from Federer in six attempts and a shock looked on the cards when he had a break point in the opening game of the second set.
Federer, who will be seeking a ninth Wimbledon title next month, eventually found some magic with a backhand winner to break for a 4-2 lead but the 36-year-old handed the advantage straight back in the next game.
He then broke to love in the 10th game to take the match into a decider that became one-way traffic as Federer surged into a 4-1 lead.