Hosts Egypt will face DR Congo, Uganda and Zimbabwe in Group A at the 2019 Africa Cup of Nations.
Defending champions Cameroon are in Group F with Ghana, Benin and Guinea-Bissau.
The tournament will take place from 21 June to 19 July, meaning Europe-based players will not miss club games.
It is the biggest Afcon yet, with 24 teams, and the first to be held in Europe’s summer rather than January or February.
The draw was held next to the pyramids of Giza.
Morocco coach Herve Renard is looking to win an unprecedented third Africa Cup of Nations – with a third team. The Atlas Lions are in Group D with one of the previous teams he won it with, the Ivory Coast. South Africa and neighbouring Namibia complete that group.
The first game of the tournament will be Egypt – who are likely to have Liverpool star Mohamed Salah in their team – against Zimbabwe on 21 June at Cairo Stadium.
Two of the three tournament debutants – Madagascar and Burundi – are in Group B with Nigeria and Guinea.
The other new team, Mauritania, are in Group E with Tunisia, Mali and Angola.
Senegal and Algeria are alongside Kenya and Tanzania, who have only qualified once before – in 1980 – in Group C.
Two teams from each group will go into the last 16, with the four best third-placed teams also progressing.
Egypt’s assistant coach, Hany Ramzy, said after the draw that the Pharaohs were “comfortable” with their pool.
“We are confident, we are here in our land with the supporters behind us, so we have to work hard to reach the final.”
Talking about the opening game against Zimbabwe, ranked more than 50 places below them, he acknowledged that the Warriors will still pose a test to the host nation.
“Whoever you play against, the opening game will be tough, but I think we can win the match,” he said.
“The big difference [in quality] between teams is not really there anymore, like it was 10 years ago in Africa. Now every team has players who play in Europe so they have the experience to play at a high level.
“But when you want to win a big tournament like the Africa Cup you have to win against small and big teams.”
Draw in full
|Group A||Group B||Group C||Group D||Group E||Group F|
|DR Congo||Nigeria||Algeria||Cote D’Ivoire||Mali||Ghana|