South Sudan thrashed Djibouti 6-0 in Juba on Tuesday to overturn a first leg deficit and win 6-2 overall.
Comoros go through after a 1-1 draw with Mauritius gave them a 3-1 aggregate win.
South Sudan progress to play in Group C with Mali, Gabon and Burundi.
They were in front after just 12 minutes and had scored four times before the break, thanks to two goals from James Joseph, and one each from Robert Duku and Dominic Abui.
Ater Thomas and Khemis Leon scored in the second half to round things off.
Comoros now advance to Group B to play alongside Morocco, Malawi and reigning champions Cameroon.
The Indomitable Lions will qualify automatically as hosts no matter where they finish in the final standings.
Greece-based Ben El Fardou extended Comoros' overall lead in the 13th minute with a header from the edge of the area.
It was to be his last contribution following a clash of heads with Walter Saint Martin as he scored his goal meant he had to be substituted.
Mauritius were lucky not to go further behind as the woodwork and goalkeeper Kevin Jean Louis came to their rescue.
The hosts equalised in injury time at the end of the first half as Comoros failed to defend a corner and the ball fell Ipswich Town's Kevin Bru whose shot was deflected into the net by Saint Martin.
Mauritius once again ended the game with 10 men after Andy Patate was shown a straight red card in the 80th minute, they had also ended the first leg a man down after Emmanuel Vincent was sent off.
The group stage of the 2019 Nations Cup qualifying begins on the first weekend in June with the 12 group winners automatically earning a place in the finals.
The three best runners-up will also advance to the tournament in Cameroon.
Draw in full:
A: Senegal, Equatorial Guinea, Sudan, Madagascar
B: Cameroon, Morocco, Malawi, Comoros
C: Mali, Gabon, Burundi, South Sudan
D: Algeria, Togo, Benin, The Gambia
E: Nigeria, South Africa, Libya, Seychelles
F: Ghana, Ethiopia, Sierra Leone, Kenya
G: DR Congo, Congo, Zimbabwe, Liberia
H: Ivory Coast, Guinea, Central African Republic, Rwanda
I: Burkina Faso, Angola, Botswana, Mauritania
J: Tunisia, Egypt, Niger, Swaziland
K: Zambia, Mozambique, Guinea-Bissau, Namibia
L: Cape Verde, Uganda, Tanzania, Lesotho