Madagascar will make their AFCON debut next year after a sensational win over Equatorial Guinea at the Stade Municipal de Mahamasina.
A goal from Thailand-based midfielder Njiva Rakotoharimalala sent the Islanders to their first ever Africa Cup of Nations finals.
The 26-year-old scored the only goal of the game just before half-time as the Malagasy beat the visiting side.
The result puts Madagascar on ten points in Group A to guarantee them a place in Cameroon next year.
There were two drawn matches in Group B as Comoros grabbed a 2-2 against visiting Morocco and Malawi held Clarence Seedorf's Cameroon to a 0-0 stalemate.
El Fardou Ben Mohamed, who plays for UEFA Champions League participants side Red Star Belgrade, opened the scoring after just eight minutes to give Comoros a shock lead.
The Moroccans then fought back with two second-half goals from Khalid Boutaib and Nordin Amrabaat to take the lead.
The hosts kept battling and Ben Mohamed was on target again in injury time for absolute scenes of pandemonium at the end of the match to earn a point for Comoros.
The results mean that Cameroon top the group with eight points, but they have qualified automatically as the Nations Cup hosts leaving just one more place up for grabs from the group.
Morocco lead the way in the race to the finals on seven points, Malawi move to four points and Comoros are on two - with all the teams having played four matches.
Three teams remain in contention to qualify after Gabon beat hosts South Sudan 1-0 and Burundi held visiting Mali to a 1-1 draw.
Midfielder Andre Biyogo Poko won the match for Gabon with a goal five minutes after half-time.
Gabon played without superstar striker Pierre-Emerick Aubameyang after he did not travel with the team after a dispute with Fegafoot.
Burundi took the lead in Bujumbura through striker Fiston Abdul Razak before Mamadou Fofana levelled the score for the visitors.
Mali lead the way with eight points just one ahead of Gabon with Burundi third on six points.
Egypt secured a 2-0 win over Swaziland to maintain their dominance.
The win came thanks to a headed goal from Ahmed Hegazi after 19 minutes and well-worked team goal that was finished by Marwan Mohsen early in the second half.
The Pharaohs are now on the verge of qualifying for the finals with nine points while eSwatini are the second side eliminated with Sudan.