Hakan Yakin's double strike ensured that Switzerland ended their Euro 2008 campaign on a high at the expense of Group A table-toppers Portugal.
After a goalless first half, Yakin gave Switzerland the lead when he slotted in through the legs of keeper Ricardo.
He scored his second, and third of the championship, with a firmly struck penalty after Fernando Meira fouled substitute Tranquillo Barnetta.
Portugal's Pepe had a shot saved and Nani hit the outside of the upright.
In fact, for the first 50 minutes of the match Portugal looked more likely to come away with victory and keep their 100% group record intact.
Most of their forays forward were led by the wizardry of Ricardo Quaresma and Manchester United's Nani, who were two of eight players brought into the starting XI by Luiz Felipe Scolari.
Nani, who was a nuisance down the left, came close to helping Portugal take the lead when his 35-yard free-kick was flicked on by team-mate Pepe only for it to be pushed on to the crossbar by Pascal Zuberbuhler.
Nani himself squandered Portugal's best opportunity soon after the restart when he pounced on Stephan Lichtsteiner's error only to sidefoot his 10-yard shot on to the right-hand upright with just the keeper to beat.
Former Tottenham forward Helder Postiga, in for Nuno Gomes, also wasted a fantastic opportunity to give his side the lead when his low shot inside the box was blocked by the leg of defender Philippe Senderos.
The Swiss also had two great chances in the opening 45 minutes when Ricardo was forced into tipping over Gokhan Inler's 25-yard dipping strike while Yakin saw his fierce header palmed round the post.
But Yakin finally found the net with 20 minutes of the match remaining when he was fed in by Eren Derdiyok's deft flick before calmly placing the ball under Ricardo.
And late in the game, the hard-working forward smashed home his second from the spot to delight the home fans and coach Kobi Kuhn who was overseeing his final match in charge of the Swiss.
Switzerland: Zuberbuhler, Lichtsteiner (Grichting 85), Muller, Senderos, Magnin, Behrami, Gelson, Inler, Vonlanthen (Barnetta 61), Yakin (Cabanas 86), Derdiyok.
Subs Not Used: Benaglio, Jakupovic, Djourou, Huggel, Gygax, Spycher, Degen, Frei, Streller.
Booked: Yakin, Vonlanthen, Barnetta, Gelson.
Goals: Yakin 71, 83 pen.
Portugal: Ricardo, Miguel, Pepe, Bruno Alves, Ferreira (Jorge Ribeiro 41), Fernando Meira, Veloso (Joao Moutinho 70), Raul Meireles, Quaresma, Postiga (Hugo Almeida 74), Nani.
Subs Not Used: Quim, Rui Patricio, Bosingwa, Ronaldo, Petit, Simao, Carvalho, Deco, Nuno Gomes.
Booked: Ferreira, Jorge Ribeiro, Fernando Meira, Miguel.
Ref: Konrad Plautz (Austria).