Morocco won by default after Algeria, Zambia and a joint bid from Benin and Nigeria all withdrew before the vote of the Confederation of African Football's executive committee in Cairo on Wednesday.
The north African country was a runaway favorite and will see the decision as a boost to their hopes of co-hosting the 2030 World Cup with Portugal and Spain, Reuters reported.
It is only the second time that Morocco will host Africa's most popular sporting event, almost four decades after the previous time in 1988.
The joint East African bid for 2027 returns the finals to the region for the first time since 1976.
They beat Botswana, Egypt and Senegal in a vote of the CAF executive committee. Algeria were also a candidate but withdrew on Tuesday.