"It has been a difficult year with a lot of practice, training and rehab so I am very happy to be back on the court," Federer said.
"I do not
know if I will ever be going to win this tournament again so I will enjoy this one," said the Swiss, who has won eight Wimbledon titles.
The 35-year-old, defeated in his first comeback match in Stuttgart last week, took control from the start with an early break and kept world number 12 Zverev on his toes.
He earned a second break point with some deft volleying, which he pounced on to race through the first set in 24 minutes.
Zverev, who beat the Swiss in last year's semi-final and has already won three titles this year, had a chance to break at the start of the second set.
But he simply could not discover a chink in Federer's armour, even as he attempted to mix up his game by forcing the Swiss to come to the net more often.
A superb dropshot put Federer 5-2 ahead and sealed Zverev's fate before he won the match on his first match point with a crosscourt volley.
In doing so, he became the first player to beat both Zverev brothers at the same event, having defeated older sibling Mischa in the round of 16.