Richard Mbulu's diving header handed Malawi a 1-0 victory over Uganda on Monday and a place at the Africa Cup of Nations finals for only the third time.
The triumph in Blantyre secured Malawi the runners-up spot in Group B, finishing behind already-qualified Burkina Faso but ahead of Uganda.
Mbulu netted after 15 minutes for Malawi, who only previously qualified in 1984 and 2010 and the feat will come as a major boost to football in one of Africa's poorest countries.
They are the 19th country to qualify for next January's final. The final five places at the 24-team tournament will be settled on Tuesday.
Burkina Faso finished with 12 points in the group after Bertrand Traore's 49th minute strike sealed a 1-0 win over South Sudan in Ouagadougou. Malawi were second on 10 points and Uganda third with eight. South Sudan lost five of their six qualifiers to finish bottom.
All of Monday's other qualifiers had no bearing on qualification but settled the placings in several groups.
Mohamed Salah scored twice in his first home appearance with Egypt in almost two years as they beat the Comoros Islands 4-0 in Cairo to finish the campaign unbeaten. Both countries had already qualified for the finals from Group G.
Kenya finished third as they won 2-1 away in Togo, likely marking the end of the long career of Frenchman Claude Le Roy, now 73, who has coached at nine Cup of Nations finals.
Gabon and Gambia, who advanced from Group D, both lost their final outings as Angola and the Democratic Republic of Congo won back some pride after failing to qualify.