Defending champion Federer only landed 42 per cent of his first serves during the first set but an early break helped him take the lead against an awkward opponent cheered on by a home crowd.
"He had a clear game plan with a lot of variation so I never really got into a rally," Federer said. "He was also unpredictable for me."
Another early break in the second set combined with an improved service ratio earned top seed Federer a place in the quarter-finals where he faces Frenchman Julien Benneteau, who he beat twice on the grass courts of Wimbledon last year.
Federer won at the London Olympics in straight sets but had to overcome a two-set deficit weeks earlier on his way to his 17th Grand Slam title.
"It will be tough as he (Benneteau) serves and returns well, while he played convincing matches in the first two rounds," the Swiss added.
Second seed Juan Martin Del Potro, beaten by Federer in last year's final, kept his best tennis for the big points as he struggled before beating wild card Ernests Gulbis 7-6 6-3.
"The first set was tough and quite a battle and I had some luck on the final point in the tiebreak," the Argentine said.
Latvian Gulbis impressed with his serve in the second set when he hit five straight aces, but a break in the eight game was enough for Del Potro to clinch the match.
"Matches like this are decided on one or two points per set, and I was at my best in those moments," Del Potro added.
In the quarter-final, Del Potro will meet Finn Jarkko Nieminen who needed three sets to overcome German qualifier Matthias Bachinger 6-3 5-7 6-3.
Fourth seed Richard Gasquet suffered a 6-4 6-4 defeat against Marcos Baghdatis from Cyprus.
Gasquet had a perfect start to the year with titles in Doha and Montpellier, reaching the fourth round at the Australian Open in between, but an early break in each set was too much for the Frenchman. Baghdatis next meets Grigor Dimitrov.
ATP Rotterdam results
1-Roger Federer (Switzerland) beat Thiemo de Bakker (Netherlands) 6-3 6-4
2-Juan Martin Del Potro (Argentina) beat Ernests Gulbis (Latvia) 7-6(5) 6-3
Marcos Baghdatis (Cyprus) beat 4-Richard Gasquet (France) 6-4 6-4
Jarkko Nieminen (Finland) beat Matthias Bachinger (Germany) 6-3 5-7 6-3
Martin Klizan (Slovakia) beat Igor Sijsling (Netherlands) 6-2 6-4
ATP San Jose results
1-Milos Raonic (Canada) beat Michael Russell (U.S.) 6-2 7-5
3-Sam Querrey (U.S.) beat Lleyton Hewitt (Australia) 7-6(6) 1-6 7-6(4)
6-Denis Istomin (Uzbekistan) beat Benjamin Becker (Germany) 6-3 6-7(5) 6-2
8-Xavier Malisse (Belgium) beat Matthew Ebden (Australia) 5-7 7-5 7-6(1)
Alejandro Falla (Colombia) beat 7-Marinko Matosevic (Australia) 6-4 6-4
Steve Johnson (U.S.) beat Tim Smyczek (U.S.) 6-3 6-3
- Sports & Recreation
- Juan Martin Del Potro
- Ernests Gulbis