Ahmad won 34 of the 54 votes in the election, which was held in Ethiopia’s capital Addis Ababa on Thursday.
The result means a change in leadership for the first time since Cameroonian Hayatou took charge in 1988.
Ahmad, who appeared very emotional, becomes only the seventh CAF president in the body’s 60-year history.
The result was greeted by cheers at the CAf congress as Ahmad was carried on the shoulders of jubilant supporters to the podium after the result was announced.
In contrast, Hayatou was led from the auditorium by aides but he told reporters as he departed: “It is not that bad.”
Ahmad later added: “When you try to do something, you mean that you can do it. If I can’t do it, I never stand.
“This is sweet victory. When you work hard for years and months and you succeed, that is great.”
watch video of celebration https://www.youtube.com/watch?v=AhqOpyZtPnE