The defending champion raced through the opening set in just 19 minutes and Mayer could only delay the Swiss star when he stirred to life in the second set, Federer eventually taking a 6-0 7-6 (7-1) win in Halle.
At his favourite warm-up event for Wimbledon, Federer received a warm reception, despite the presence of a German on court, and he snatched a break at the first opportunity.
Mayer was being mauled by shots from all angles and surrendered his serve twice more as Federer motored into the lead.
The second set was more taxing for the world No 2, with Mayer standing firm until the tie-breaker, when Federer pulled 6-1 ahead and sealed victory with a backhand passing shot. ?? ?? ??
He will next face Ivo Karlovic, who sent down a record 45 aces during his three-set upset win over Tomas Berdych.