Wawrinka took three hours and 21 minutes to finally dispose of Baghdatis, in four sets, 6-3, 6-2, 6-7 (1/7), 7-6 (9/7).
Wawrinka, ranked 10th in the world, will next meet fifth-ranked Tomas Berdych, from the Czech Republic, on Tuesday.
It marks the third time this year that Wawrinka has reached the final 16 of a major tournament and the result also makes 2013 the best year of his career, with 39 victories against 15 defeats.
But the Lausanne native struggled against Bagdhatis, ranked 53rd in the world by ATP, losing the third set after winning the first two before prevailing in the final set.
On Saturday, Federer had an easier time of it, handily beating 63rd-ranked French left-hander Adrian Mannarino in three sets 6-3, 6-0, 6-2.
The Basel native, seeking his 18th Grand Slam title, next faces Spanish 19th seed Tommy Robredo, who is winless in 10 matches against the Swiss star.
Number two ranked Rafael Nadal, of Spain, also cruised into the fourth round by beating Ivan Dodig, of Croatia, 6-4, 6-3, 6-3.
Nadal will take on 22nd seed Philipp Kohlschreiber, from Germany.
If Federer and Nadal win their next matches they will meet in a first ever Grand Slam matchup on the Flushing Meadows hardcourts.