Kevin Anderson captured his seventh ATP tour title, his first since the Maharashtra Open at Pune in January 2019.
The 35-year-old has battled knee problems over the past two years but set those setbacks and poor recent form on grass aside to beat Chilean Marcelo Tomas Barrios Vera.
It was Federer's earliest departure from Wimbledon since his shock second round defeat against Sergiy Stakhovsky in 2013.
The big South African Anderson, ranked at eight in the world, reached the Wimbledon last 16 on Friday for the fourth time.
Top seed Cilic from Croatia outplayed eighth seed Frenchman Pierre-Hugues Herbert 6-3 6-2 in 64 minutes while Anderson survived a mighty scare from a dogged Mikhail Kukushkin.
The big-serving 31-year-old Kevin Anderson fell to the top-ranked Rafael Nadal 6-3, 6-3, 6-4 at Arthur Ashe Stadium.
Kevin Anderson's joy and enthusiasm were evident after his impressive 4-6, 7-5, 6-3, 6-4 win over Pablo Carreno Busta.
Cliff Drysdale was the last South African man in the US final in 1965 but he was defeated by Manuel Santana.
Football, rugby and cricket dominate the sport scene in the republic, taking most of the sponsorship money and the media space.