In 1971, a military coup overthrew the President of Uganda, Milton Obote. Colonel Idi Amin installed himself as new Ugandan President and ruled the country under a repressive dictatorship. However, this takeover was initially welcomed by many Ugandans, as Obote had become deeply unpopular in sections of the country's population and Amin presented himself as reformer. He freed several opposition figures who had been imprisoned under Obote, including Shaban Opolot, Grace Ibingira, and Benedicto Kiwanuka. The coup resulted in a deterioration of relations with neighbouring Tanzania, as Tanzanian President Julius Nyerere withheld diplomatic recognition of the new government and offered asylum to Obote and his supporters. After the coup, Amin launched purges of his enemies, and empowered his own followers to consolidate his regime. The country's military, officially known as Uganda Army (UA), was most affected by this development. Much of its leadership was killed or expelled, while members of ethnic and religious groups supportive of Amin were recruited and promoted "en masse". A large number of soldiers and opposition figures targeted by the purges consequently fled into exile. They set up training camps and organized militant groups in Sudan and Tanzania. Sudanese President Jaafar Nimeiry opposed Amin due to his support for Sudanese Anyanya rebels, while Tanzanian President Nyerere had close ties with Obote and had supported his socialist orientation.