Renato Sanches broke the deadlock for Portugal and Dusan Tadic scored the equalizer at Lisbon's Estadio da Luz as the draw will be enough for Portugal to qualify for the tournament.
But Mitrovic's stoppage time winner sent Serbia directly to the 2022 World Cup in Qatar.
Serbia jumped to the top of Group A with 20 points, three points ahead of Portugal, which sealed a playoff spot.
Ireland meanwhile secured a 3-0 win over Luxembourg, finishing the qualifiers in third spot with nine points.
Luxembourg took fourth spot on goal difference and Azerbaijan are at the bottom of the group with only one point.