Ivory Coast, who beat Ghana on penalties in the 2015 final, are in Group C against Togo, Morocco and the Democratic Republic of Congo.
Hosts Gabon, who saw political turmoil after a disputed election in August, will stage the opening match in Libreville on January 14 against Guinea-Bissau, who make their first appearance in the 16-nation tournament.
Cameroon and Burkina Faso are also in Group A.
The other group favourites, Algeria and Ghana, start against Zimbabwe and Uganda respectively.
Algeria have the toughest first round in Group B where they also take on Tunisia and Senegal for one of the two qualifying places for the quarter-finals.
Ghana are the team to beat in Group D. Apart from Uganda, they will take on Egypt, making their return to the contest after missing three finals, and Mali.
The final is in Libreville on February 5.
The draw produced three groups containing three of the top 10 ranked football nations in Africa, according to FIFA.
Algeria (2), Senegal (3) and Tunisia (4) are in one mini-league, Ivory Coast (1), DR Congo (6) and Morocco (10) in another and Ghana (5), Egypt (7) and Mali (9) in a third.
A lot of teams will get to know each other extremely well, too, as Ivory Coast and Morocco also share a 2018 World Cup qualifying group, as do Ghana, Egypt and Uganda.
Ivory Coast were not impressive in qualifying, drawing three of four matches against Sierra Leone and Sudan, and Morocco are probably a team they wanted to dodge.
The Moroccans are coached by Herve Renard, the charismatic Frenchman who masterminded the Ivorians’ triumph in Equatorial Guinea last year.
He then left for a brief, unsuccessful spell in the French Ligue 1 before being hired by Morocco, and they became the first qualifiers for the 2017 tournament.
Renard has won the Cup of Nations twice, taking no-hopers Zambia to the title in Gabon four years ago.
Veteran Togo coach Claude le Roy has won it once, with Cameroon in 1988, and Gabon will mark his ninth appearance at the Cup of Nations finals.
He has failed to reach the knockout stage only once.
Being grouped with Ghana offers Egypt yet another chance to avenge one of their most humiliating results, a 6-1 thrashing by the Black Stars in a 2014 World Cup qualifier.
No team will be more excited about going to Gabon in January than Uganda — the last time they qualified was in 1978 when the notorious Idi Amin ruled the east African state.
Although Gabon are the second lowest ranked team among the 16 contenders, they look set to make the last eight, probably with four-time champions Cameroon.
The hosts rely heavily on 2015 African Footballer of the Year Pierre-Emerick Aubameyang, a prolific goalscorer with German giants Borussia Dortmund.
During the draw ceremony, Gabonese officials emphasised that the country was ready to host a tournament they co-staged with neighbours Equatorial Guinea in 2012.
A disputed presidential election victory by incumbent Ali Bongo two months ago triggered riots with opposition parties claiming vote fraud.
Complete fixtures for 2017 Africa Cup of Nations in Gabon after draw was made in Libreville on Wednesday (all times GMT):
(Libreville unless noted)
Gabon v Guinea-Bissau 1600, Burkina Faso v Cameroon 1900
Gabon v Burkina Faso 1600, Cameroon v Guinea-Bissau 1900
Gabon v Cameroon 1900
Guinea-Bissau v Burkina Faso 1900
(Franceville unless noted)
Algeria v Zimbabwe 1600, Tunisia v Senegal 1900
Algeria v Tunisia 1600, Senegal v Zimbabwe 1900
Algeria v Senegal 1900
Zimbabwe v Tunisia 1900
(Oyem unless noted)
Ivory Coast (holders) v Togo 1600, Democratic Republic of Congo v Morocco 1900
Ivory Coast v DR Congo 1600, Morocco v Togo 1900
Ivory Coast v Morocco 1900
Togo v DR Congo 1900
(Port-Gentil unless noted)
Ghana v Uganda 1600, Mali v Egypt 1900
Ghana v Mali 1600, Egypt v Uganda 1900
Ghana v Egypt 1900
Uganda v Mali 1900
(1) Group A winners v Group B runners-up 1600
(2) Group B winners v Group A runners-up 1900
(3) Group C winners v Group D runners-up 1600
(4) Group D winners v Group C runners-up 1900
Quarter-final 1 winners v quarter-final 4 winners 1900
Quarter-final 2 winners v quarter-final 3 winners 1900
Losing semi-finalists 1900
At Libreville 1900