A goal from Thailand-based Njiva Rakotoharimalala sent Madagascar to their first ever Africa Cup of Nations finals.
The 26-year-old midfielder scored the only goal of the game just before half-time as the Malagasy beat visiting Equatorial Guinea.
The result puts Madagascar on ten points in Group A to guarantee them a place in Cameroon next year.
Senegal will join them in the finals if they can win in Sudan later on Tuesday.
The games was played in the city of Vontovorona after Madagascar were banned from using the Mahamasina Stadium in Antananarivo for “three matches or three months”.
The suspension was imposed by the Confederation of Africa Football following a stampede at the national stadium in September, when one person was killed and nearly 40 others were injured.
Madagascar become the 40th different nation to qualify for the Nations Cup finals.
In Group B Comoros grabbed a 2-2 against visiting Morocco.
El Fardou Ben Mohamed, who plays for Serbian 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 at the end of the match to earn a point for Comoros.
The result takes Morocco to seven points from four matches with Comoros on two.
There are two more qualifying rounds left to play one in November and the final matches will be in March next year.
Source:BBC