Serbia locked up its spot at Euro 2024 after drawing 2-2 with Bulgaria in their final European Championship qualifier on Sunday.
The already-qualified Hungary also beat Montenegro 3-1, led by midfielder Dominik Szoboszlai’s brace.
Serbia needed a draw or for Montenegro to not beat Hungary to advance to next year’s tournament in Germany.
There was a moment when Serbia appeared to be in trouble after Montenegro went ahead 1-0 against Hungary while Bulgaria led Serbia 2-1.
But Serbia defender Srdan Babic’s equalizer in the 82nd ensured that it needed no help.
Hungary finished Group G with 18 points. Serbia was second with 14, and Montenegro third with 11.
Hungary secured its place on Thursday when it won at Bulgaria. The match was marred by violence when local fans clashed with police on the streets of Sofia during a protest over the management of the national soccer union.
Only the top two finishers from each of the 10 groups advance. Another three spots will be determined in a playoff linked to performances in the Nations League. Host Germany automatically qualifies.