The draw for the 2018 African Nations Championship (CHAN) was made in Rabat on Friday night, with Nigeria grouped alongside Libya – the only former winners in the 16 teams taking part.
The tournament, which is for African footballers based in their own domestic leagues, will be staged in Morocco between 12th January and the 4th of February.
The Nigerians are making a third consecutive appearance in the biennial event, and will also face Rwanda and Equatorial Guinea in group C.
Nigeria finished 3rd in 2014 in South Africa, but failed to reach the knockout phase in Rwanda last year.
Equatorial Guinea are debutants and qualified without kicking a ball after opponents Gabon withdrew from the regional qualifying competition.
Namibia are the other debutants in the competition and are in group B alongside Ivory Coast, Zambia and Uganda.
Group A has Morocco, Guinea, Sudan and Mauritania while Angola, Cameroon, Congo Brazzaville and Burkina Faso are in group D.