Fulham striker Aleksandar Mitrovic scored a dramatic late winner as Serbia booked their place at next year’s World Cup and condemned Portugal to the play-offs.
Hosts Portugal only needed a draw to qualify and looked to have done enough, with Renato Sanches’ opener cancelled out by Dusan Tadic’s equaliser.
Mitrovic had started the game on the bench but was sent on at half-time.
He was quiet until he popped up in the final seconds to head in the winner.
The late goal sparked jubilant celebrations on the Serbia bench and silenced the stunned home crowd.
Serbia finish top of Group A with 20 points, three more than Portugal, whose hopes of playing in Qatar next year rest on two rounds of play-offs in March.
It had looked like being a long night for the visitors when they fell behind inside just two minutes when Sanches finished confidently after Bernardo Silva had won possession.
But Serbia did not let their heads drop and deservedly equalised when Rui Patricio failed to keep out Tadic’s shot, which crept over the line.
Cristiano Ronaldo, himself familiar with scoring dramatic late goals with Manchester United this season, was quiet and came closest with a free-kick in the first half.
Instead it was Mitrovic who grabbed the headlines as he was left unmarked to meet a late cross and send a downward header into the back of the net and claim a famous win for Serbia.