Federer, who slipped outside the top four after flopping at Wimbledon, went out 6-3 6-4 in one hour and five minutes to the big-serving German, who is unseeded for the tournament.
It was top seed and home favourite Federer's first match at the Swiss Open, having been granted a round-one bye. Last week he was ousted from Hamburg by world number 114 Federico Delbonis.
"I've had serious problems with the back, I had to get some anti-inflammatories last week in Hamburg due to the back pain," Federer said.
"It was so tough to play and move out there today. I'll just have to take treatment and see how it all goes."
His participation at next month's Montreal Masters is now in doubt as the former world number one struggles to find form and fitness in time for the US Open.
The Swiss master, who has won a record 17 Grand Slam titles, has been in relatively poor form since losing to Novak Djokovic in last November's World Tour Finals.
He failed to reach a final in the first four months of the season and, while he won his customary pre-Wimbledon title at Halle, results in the Slams have worsened, going out in the Australian Open semis, French Open quarters and the second round at the All-England club.
His ranking of number five is the lowest it has been in a decade, with the rise of Djokovic and Andy Murray seeing him eclipsed as the world's best hard court and grass player.
The 31-year-old appears to be in decline, but a change in racquet may explain his poor form.
Federer actually beat Brands last week in Hamburg. But on Thursday he saw the German deliver 11 aces and save five break points as he blasted his way to victory.
"It helped that I already played him in Hamburg last week," Brands said. "Of course you are very impressed when you face him on the court for the first time.
"It's completely different from what you see when you watch him on TV once you see him on the other side of the court."
Brands will next face Victor Hanescu after his eighth-seeded opponent Roberto Bautista withdrew from their clash injured.
In other matches at Gstaad, third seed Janko Tipsarevic was surprisingly beaten 6-2 6-2 by world number 57 Robin Haase.
Dutchman Haase faces Marcel Granollers in the quarter-finals after he won his second-round match 6-2 7-5 - against Delbonis, who beat Federer last time out.
Round two results:
Daniel Brands (Germany) beat 1-Roger Federer (Switzerland) 6-3 6-4
Robin Haase (Netherlands) beat 3-Janko Tipsarevic (Serbia) 6-2 6-2
Victor Hanescu (Romania) beat 8-Roberto Bautista (Spain) 7-6(2) 3-2 (Bautista retired)
Marcel Granollers (Spain) beat Federico Delbonis (Argentina) 6-2 7-5