Morocco and Sudan have taken the two remaining qualifying spots for the 2012 Africa Cup of Nations.
Morocco beat Tanzania 3-1 on Sunday night to finish top of Group D ahead of Central African Republic (CAR), who were beaten 2-0 in Algeria.
Those results mean that Sudan take the remaining best-placed runners-up spot, for their performance finishing behind Ghana in Group I.
Pool D runners-up CAR did not have enough points to overtake Sudan.
Marouane Chamakh, Adel Taraabt and M’Bark Boussoufa got the goals for Morocco in Marrakech – with Taraabt getting a place in the starting line-up at the last moment following an injury to Youssf Hadji in the warm-up.
It was Taarabt’s first appearance for Morocco since he walked out on the team earlier in the qualifying campaign and he capped it with a stunning free-kick.
Algeria’s win over CAR proved academic for them given Morocco’s victory but it was a spirited performance by the Desert Foxes, who needed victory by a huge margin to be in contention even if the other result had gone their way.
Hassan Yebda put them in front after just a couple of minutes before Foued Kadir doubled the lead on the half-hour.
Sudan’s late entry into the tournament meant that East Africa will be represented at the Nations Cup for the third straight tournament in a row.
The Nile Crocodiles squeezed through above Cape Verde, who had a similar number of points out of the best second-placed sides but an inferior goal difference to Sudan.
This qualifying campaign will be remembered for the shock eliminations of defending champions Egypt and fellow heavyweights Nigeria and Cameroon.
Meanwhile, Niger and Botswana rewrote the history books when qualifying for their first Nations Cup finals – while co-host Equatorial Guinea will also be making their tournament bow.
The 2012 Nations Cup opens in Equatorial Guinea on 21 January, with the final taking place in the Gabonese capital Libreville on 12 February.