Wawrinka was cruising at 4-0 up in the second set, then failed to serve out the match at 5-3 before clinching victory in the tiebreaker.
Fourth-seeded Juan Monaco of Argentina eased past Guillermo Garcia-Lopez of Spain 6-1, 6-2 under warm sunshine in the ski resort venue. Monaco will face Mikhail Youzhny of Russia on Friday, in the same half of the draw as Federer.
Youzhny, the No. 6 seed, beat his second-round opponent Pablo Andujar of Spain, 6-3, 4-6, 6-3.
Fifth-seeded Feliciano Lopez of Spain won 6-4, 6-3 against Andrey Kuznetsov of Russia to set up a quarterfinal against Wawrinka.