- Oops!Something went wrong.Please try again later.
The hosts needed just a point in Lisbon to seal their position as winners of Group A, and looked well on course to do so when Renato Sanchez put them in front inside two minutes.
But Dusan Tadic equalised in the first-half, before Mitrovic headed home late on to leave Cristiano Ronaldo and his teammates devastated.
Portugal will now have to hope they can reach the World Cup through the play-offs.
In that same group, the Republic of Ireland signed off their campaign with a 3-0 away win over Luxembourg, who they lost to at home back in March.
Shane Duffy scored the opening goal, halfway through the second period, before Chiedozie Ogbene and Callum Robinson also got on the scoresheet.
The victory means Ireland finished the group in third place.
Watch: Warm up routine
Luis Enrique’s side only needed a point to finish above Sweden, but while it remained goalless here was a tense atmosphere.
Zlatan Ibrahimovic was brought off the bench with 20 minutes remaining, as Sweden tried to find a late winner that would seem them go above Spain.
However, it was another substitute striker in Morata that proved to be the hero and give Spain the 1-0 win.
Earlier in the day, Croatia booked their place at the World Cup with a dramatic 1-0 win.
Russia needed just a point to secure top spot in the group, but an 81st-minute own-goal gave Croatia the win and left Russia having to go through the play-offs.
Germany eased past Armenia 4-1, to make it 27 points out of a possible 30 in Group J. Kai Havertz and Ilkay Gundogan were both among the goals.
North Macedonia’s 3-1 win over Iceland meant they they finished second behind Germany, and therefore progress to the play-offs.
Watch: HIIT training 101