An own goal by Brazilian defender Dani Alves three minutes into the second half was enough to give Switzerland a 1-0 win in front of delrious supporters at the St. Jakob-Park stadium in Basel.
The Barcelona star headed the ball into his own net.
The friendly international result ended a streak of 11 undefeated games for Brazil, recent winners of the Confederations Cup.
They were last defeated by England in February at Wembley Stadium, where they lost 2-1.
Brazil were playing their first match since winning the Confederations Cup in June, and a tense opening half saw three players booked in the first 24 minutes, with Switzerland's Philippe Senderos and Valon Behrami and Brazil's Neymar all being shown yellow cards.
The underdog Swiss were aided by Brazil’s missed opportunities as the Brazilian defence were rarely challenged.
The win nevertheless showed the Swiss side’s potential, coming ahead of next year's World Cup in Brazil and 14 months after Switzerland beat Germany 5-3 in another friendly game on the Basel pitch.
The result came on a busy night for international football with England edging Scotland 3-2 at Wembley, Portugal tying the Netherlands 1-1 at home and Argentina beating Italy 2-1 in Rome.
Among other friendlies Germany drew 3-3 at home against Paraguay, the US beat Bosnia Hercegovina 3-2 in a come-from-behind win and Sweden beat rivals Norway 4-2.