Federer saw off Vacek, who is ranked as the world 342nd
Roger Federer came through a difficult match against Czech qualifier Jan Vacek 7-5 6-3 to reach the quarter-finals of the Gerry Weber Open in Halle.
Vacek saved three break points in the second game of the opening set, forcing Federer to wait until the 12th game to secure the first break.
Federer, who struggled to find his rhythm, took a decisive lead 4-3 in the second to wrap up the match.
It was the world number one's 56th straight victory on grass.
"It was difficult," Federer said. "When it happens you can't play your game and it isn't working, then it's a surprise. It was an awkward sort of match.
"On the easy wins you feel good and don't think about it; on the hard ones you think about what you have to do better."
Federer traditionally uses Halle as a warm-up for Wimbledon and has won four titles at the event, going on to win Wimbledon three weeks later each time.
In other matches, fifth seed Marcos Baghdatis saw off French veteran Fabrice Santoro 6-4 6-3, while home hope Nicolas Kiefer beat fourth seed Mikhail Youzhny 6-2 5-7 6-3.
And France's Michael Llodra also reached the quarter-finals by beating Steve Darcis of Belgium 7-6 (8-6) 7-6 (7-3).