Ali was involved in the 1971 Ugandan coup d'état that overthrew President Milton Obote and brought Idi Amin to power. He consequently rose in the ranks during the duration of the Second Republic of Uganda, when Amin ruled the country as military dictator. Ali was appointed Minister of Finance, and used his position to organize an Islamic charity. This garnered him a lot of popular support, but also raised Amin's suspicions, as he feared Ali was attempting to construct a Muslim political base of support. In April 1978, the President organized a meeting in the capital Kampala, where he railed against ministers whom he deemed disloyal, too powerful or incompetent, including Ali. Accusing the Minister of Finance of mismanaging the Bank of Uganda and gross corruption, Amin became so angry during his speech that he threw a trashcan at Ali. Having realized that his situation was untenable, Ali got away as soon as possible. He quietly snuck out of Kampala in his private car and fled to his home in the West Nile region. When he got there, however, a group of hitmen attacked him, but he fended them off in a gunfight. Ali was convinced that his downfall and the attempted assassination had been organized by the Uganda Army commander Yusuf Gowon, a long-time rival of his. Amin subsequently stripped him of all of his military honours.