Switzerland reached the FIFA World Cup last 16 for the third consecutive time after beating Serbia 3-2 at the Stadium 974 here on Friday.
Murat Yakin's side even had a chance to top Group G if they could score one more in the stoppage time, as Brazil was stunned by Cameroon 1-0 in the other game of the group.
Brazil and Switzerland both finished the group stage with two wins and one loss, but the five-time champions were ahead on goal difference.
Xherdan Shaqiri, who scored the late winner in Switzerland's 2-1 victory over Serbia four years ago in Russia in the same stage, opened the scoring sheet on Friday night in the 20th minute as he smashed home a pass from Djibril Sow.
Switzerland would secure a berth in the round of 16 if they avoid a defeat while Serbia needed a victory to progress.
Strikers Aleksandar Mitrovic and Dusan Vlahovic both found the target in the first half to gift Serbia a 2-1 lead, but the score was levelled again one minute before the break as Breel Embolo tapped in a Silvan Widmer cross to pocket his second goal in the tournament.
Serbia's shaky defense allowed too much room for their opponents, and they suffered another blow three minutes into the second half when Shaqiri's pass met Ruben Vargas, who set up Remo Freuler's goal with a brilliant back-heel pass.
Switzerland will take on Portugal in the last 16 while Brazil face South Korea.