The 2012 co-hosts won a vote by the Confederation of African Football's executive committee in Cairo on Wednesday ahead of Algeria and Ghana. It will be the second time as hosts for the country, which is located on the west coast of Africa, having previously shared duties with Equatorial Guinea. Original hosts Libya, where a civil war has halted football, withdrew last year from staging the tournament. Gabon will use four venues for the 16-team tournament, which will be played in January and February. They will be in Libreville and Franceville, which were used in 2012, plus Port Gentil and Oyem where the stadiums will be ready in 14 months, Gabon Football Federation officials said.
All three candidate countries made presentations to the Caf executive committee on Wednesday before the ballot was taken. Caf did not make details of the voting immediately available.
Also on Wednesday, Caf conducted the draw for the qualifiers, which included Morocco and Tunisia.
Morocco had been banned from taking part in the next two editions of the tournament after they did not host the 2015 event but were reinstated after winning their appeal to the Court of Arbitration for Sport.
Tunisia avoided a ban after apologising to Caf for accusing the governing body of bias.
Morocco were placed in Group F, alongside Cape Verde, Libya and Sao Tome. Tunisia will face Togo, Liberia and Djibouti in Group A.
In one of the toughest-looking groups, 2013 champions Nigeria will take on Egypt - with both sides aiming to avoid failing to qualify for a second successive finals - Tanzania and Chad.
The winners of the 13 groups will book their place at the tournament along with the two best-placed runners-up excluding the group which contains hosts Gabon, whose matches will be considered friendlies and where only the winner will qualify.
Gabon are placed in Group I alongside reigning champions Ivory Coast, Sudan and Sierra Leone.
Full draw for 2017 Afcon qualifiers:
Group A: Tunisia, Togo, Liberia, Djibouti
Group C: Mali, Equatorial Guinea, Benin, South Sudan
Group D: Burkina Faso, Uganda, Botswana, Comoros
Group E: Zambia, Congo, Kenya, Guinea Bissau
Group F: Cape Verde, Morocco, Libya, Sao Tome
Group G: Nigeria, Egypt, Tanzania, Chad
Group I: Ivory Coast, Sudan, Sierra Leone, Gabon
Group J: Algeria, Ethiopia, Lesotho, Seychelles
Group K: Senegal, Niger, Namibia, Burundi
Group L: Guinea, Malawi, Zimbabwe, Swaziland
Group M: Cameroon, South Africa, The Gambia, Mauritania