The 31-year-old Swiss star is now ranked No. 5, his lowest in a decade since he started his run of 17 Grand Slam singles titles at Wimbledon in 2003.
Federer, seeded first, saved a first match point by serving an ace when trailing 5-3, and a second in the next game with a forehand winner. Brands, who took a set off Federer in a second-round loss at Hamburg, then ended the 65-minute match with a service winner.
Federer was returning to Gstaad for the first time since he won the title in 2004 and where he debuted on the ATP Tour in 1998 as a 17-year-old ranked No. 702.
Federer rarely loses an opening match. This defeat ranks alongside that of his round-of-64 exit in straight sets at Indian Wells, Calif., in March 2007 to Guillermo Canas of Argentina, then ranked No. 60.
Federer was hoping to tune his game in Gstaad and Hamburg after his second-round exit at Wimbledon. After a three-week break, he returned in Hamburg, testing his new racket yet citing back pains that limited his movement. He lost there in the semifinals.
Brands broke Federer to lead 4-2 in the opening set when he put away an overhead at the net. But the 26-year-old German closed the first set with two aces, among his 11 for the match. Federer immediately lost serve in the second set by netting a backhand volley and saved three break-point chances to avoid trailing 3-0.
Federer is to return next month at the Montreal Masters and then defend his Cincinnati Masters title before the U.S. Open begins Aug. 26.
Two other seeded players were ousted in the second round: Third-seeded Janko Tipsarevic of Serbia lost to Robin Haase of the Netherlands 6-2, 6-2; and eighth-seeded Roberto Bautista Agut of Spain retired against Victor Hanescu of Romania while trailing 7-6 (2), 3-2.
Also, Marcel Granollers of Spain defeated Federico Delbonis of Argentina 6-2, 7-5.