The 24-year-old from Limassol, who had lost to the Swiss master in all six of their previous meetings, saved three match points before clinching the decisive tiebreak 7-4.
Baghdatis, beaten by Federer in four sets at the 2006 Australian Open final, kissed the ground in celebration after his opponent failed to return a powerful first serve.
The Cypriot's shock win against a 16-times Grand Slam champion earned him a place in the fourth round against Spaniard Tommy Robredo, who beat Israel's Dudi Sela 6-3, 6-0 earlier in the day.
American Andy Roddick booked his place in the fourth round with a clinical 6-3, 6-4 win against Dutchman Thiemo de Bakker, where he was joined by fourth seed Andy Murray, who suffered a late wobble before beating American Michael Russell 6-3, 7-5.
In other matches, sixth-seeded Swede Robin Soderling eased past Spaniard Feliciano Lopez 7-6, 6-4 while ninth-seeded Frenchman Jo-Wilfried Tsonga came from a set down to beat Albert Montanes of Spain 4-6, 6-3, 6-3.
Second seed
Caroline Wozniacki recovered from a second-set hiccup to move into the women;s quarterfinals with a 6-3, 3-6, 6-0 victory over Russian Nadia Petrova.
Zheng Jie reached the last eight by beating Australia's Alicia Molik 6-3, 4-6, 7-6. Elena Dementieva cruised through with a 6-3, 6-3 win against Frenchwoman Aravane Rezai and will next meet Agnieszka Radwanska, who crushed 11th seed Marion Bartoli of France 6-3, 6-2.
Sixth-seeded Serb Jelena Jankovic eased past Israel's Shahar Peer 6-2, 6-2 and eighth-seeded Australian Samantha Stosur eliminated holder Vera Zvonareva of Russia 6-2, 7-5. Reuters
Deccan Herald is on WhatsApp Channels| Join now for Breaking News & Editor's Picks