In an entertaining encounter at the Kaliningrad Stadium, Aleksandar Mitrovic's header gave Serbia a half-time lead (5) before Granit Xhaka levelled proceedings with a stunning strike (52).

A win would have seen Serbia qualify for the round of 16 with one game to space, and the men in red piled men forward in the second half.

However, it was Switzerland who stole all three points when Shaqiri broke away in the dying minutes, before slotting the ball past goalkeeper Vladimir Stojkovic.

The result means Switzerland join Brazil on four points at the top of the group and only need a point against Costa Rica on Thursday (AEST) to qualify.

If Switzerland win, Serbia will need to beat Brazil in their final game to progress.

Serbia started brightly and took the lead through Mitrovic, who leapt higher than the Swiss defenders before turning Dušan Tadic's cross past goalkeeper Yann Sommer.

Switzerland then saw more of the ball without threatening their opponents' goal and went in behind at the interval.

They improved after the break though, and deservedly equalized when Xhaka thumped the ball home from the edge of the area.

The closing stages produced some end-to-end moments but it was Switzerland who nicked a late winner.