Several African kingdoms had been in place for centuries when the first Arab traders moved inland in the 1830s into what is now Uganda. British explorers, searching for the source of the Nile, arrived in the 1860s. Protestant and Catholic missionaries first entered the country in the late 1870s. In 1888, Britain assigned control of its emerging central African "sphere of interest" to the Imperial British East Africa Company. In 1890, an Anglo-German agreement confirmed British dominion over Uganda and neighboring Kenya. By 1893, the company abandoned the territory, which became a formal British protectorate in 1894. It was not until 1955 that the terms of the protectorate were expanded to include constitutional changes that would eventually lead to Uganda's independence.
Uganda's first general elections were held in 1961, and internal self-government was granted on 1 March 1962, with Benedicto Kiwanuka as prime minister. On attaining independence on 9 October 1962, Kiwanuka had been succeeded by Dr. Milton Obote, leader of the Uganda People's Congress (UPC). At the time of independence, the country comprised four regions, including the Kingdom of Buganda, traditionally among the most powerful political entities in the area. In 1963, Uganda became a republic and Mutesa II, the king of Buganda, was named president. Executive power, however, remained with the cabinet and Prime Minister Obote. After several years of conflict between those who favored a centralized state and those who preferred a loose federation with strong roles for tribally based kingdoms, Obote led a coup against the king in February 1966. He suspended the Constitution and assumed all government powers as executive president in April 1966.
In 1967, Obote promulgated a new Constitution, which granted the president greater power, proclaimed Uganda a republic, and abolished the traditional kingdoms. All opposition parties were banned in 1969. In January 1971, Obote was overthrown by the army, led by Major General Idi Amin Dada, who assumed full executive power. In February, Amin dissolved the National Assembly, assumed legislative power, suspended the Constitution, and declared himself head of state. In an "economic war" intended to free Uganda from foreign domination, Amin expelled all Asians, many of whom were engaged in trade and small industry. The next seven years were characterized by brutality virtually unmatched in history, with the ruthless extermination of any suspected opposition and an army which was allowed to trample on civil and human rights with impunity. Relations with nations around the world, and especially with the East African community, deteriorated steadily throughout the 1970s, leading to its collapse in 1977. In November 1978, Amin annexed the Kagera salient from Tanzania, which provoked the 1979 joint invasion of Uganda by Tanzanian troops and the Uganda National Liberation Army (UNLA), an umbrella organization of rebel forces. The invasion force quickly gained control of much of the southern region of Uganda, and Amin's troops capitulated. In April 1979, a Tanzanian assault force entered Kampala. Idi Amin fled to Libya and later to Saudi Arabia.
Elections held in 1980 were won by the UPC and Milton Obote became president for the second time. Obote's second term was marked by increasing guerrilla activity, to which he responded with repression and violence. Obote was overthrown in a military coup in July 1985. Over the next several months, agreement was reached between exiled opposition groups and the interim government. These talks were opposed by the National Resistance Movement (NRM) and its military wing, the National Resistance Army (NRA), led by Yoweri Museveni. Museveni assumed the presidency when the NRA took over the capital in January 1986. Unresolved conflict in the north, military adventurism in neighboring Democratic Republic of the Congo (DRC), and poor governance have destabilized the country and constitute key handicaps to sustained economic growth.