The indigenous populations of eastern Africa are thought to be the click speaking Hadza and Sandawe hunter-gatherers of Tanzania.
The first wave of migration was by Southern Cushitic speakers who moved south from Ethiopia into Tanzania. They are ancestral to the Iraqw, Gorowa, and Burunge. Based on linguistic evidence, there may also have been two movements into Tanzania of Eastern Cushitic people at about 4,000 and 2,000 years ago, originating from north of Lake Turkana.
Archaeological evidence supports the conclusion that Southern Nilotes, including the Datoog, moved south from the present-day South Sudan / Ethiopia border region into central northern Tanzania between 2,900 and 2,400 years ago.
These movements took place at approximately the same time as the settlement of the iron-making Mashariki Bantu from West Africa in the Lake Victoria and Lake Tanganyika areas. They brought with them the west African planting tradition and the primary staple of yams. They subsequently migrated out of these regions across the rest of Tanzania between 2,300 and 1,700 years ago.
Eastern Nilotic peoples, including the Maasai, represent a more recent migration from present day South Sudan within the past 500 to 1,500 years.
The people of Tanzania have been associated with the production of iron and steel. The Pare people were the main producers of highly demanded iron for peoples who occupied the mountain regions of north-eastern Tanzania. The Haya people on the western shores of Lake Victoria invented a type of high-heat blast furnace, which allowed them to forge carbon steel at temperatures exceeding 1,820 °C (3,310 °F) more than 1,500 years ago.
Travelers and merchants from the Persian Gulf and India have visited the east African coast since early in the first millennium A.D. Islam was practiced by some on the Swahili Coast as early as the eighth or ninth century A.D.
Claiming the coastal strip, Omani Sultan Said bin Sultan moved his capital to Zanzibar City in 1840. During this time, Zanzibar became the centre for the Arab slave trade. Between 65 and 90 percent of the Arab-Swahili population of Zanzibar was enslaved. One of the most infamous slave traders on the East African coast was Tippu Tip, who was the grandson of an enslaved African. The Nyamwezi slave traders operated under the leadership of Msiri and Mirambo. According to Timothy Insoll, "Figures record the exporting of 718,000 slaves from the Swahili coast during the 19th century, and the retention of 769,000 on the coast." In the 1890s, slavery was abolished.
In the late 19th century, Germany conquered the regions that are now Tanzania (minus Zanzibar) and incorporated them into German East Africa (GEA). The Supreme Council of the 1919 Paris Peace Conference awarded all of GEA to Britain on 7 May 1919, over the strenuous objections of Belgium. The British colonial secretary, Alfred Milner, and Belgium's minister plenipotentiary to the conference, Pierre Orts, then negotiated the Anglo-Belgian agreement of 30 May 1919 where Britain ceded the north-western GEA provinces of Ruanda and Urundi to Belgium. The conference's Commission on Mandates ratified this agreement on 16 July 1919. The Supreme Council accepted the agreement on 7 August 1919. On 12 July 1919, the Commission on Mandates agreed that the small Kionga Triangle south of the Rovuma River would be given to Portuguese Mozambique, with it eventually becoming part of independent Mozambique. The commission reasoned that Germany had virtually forced Portugal to cede the triangle in 1894. The Treaty of Versailles was signed on 28 July 1919, although the treaty did not take effect until 10 January 1920. On that date, the GEA was transferred officially to Britain, Belgium, and Portugal. Also on that date, "Tanganyika" became the name of the British territory.
During World War II, about 100,000 people from Tanganyika joined the Allied forces and were among the 375,000 Africans who fought with those forces. Tanganyikans fought in units of the King's African Rifles during the East African Campaign in Somalia and Abyssinia against the Italians, in Madagascar against the Vichy French during the Madagascar Campaign, and in Burma against the Japanese during the Burma Campaign. Tanganyika was an important source of food during this war, and its export income increased greatly compared to the pre-war years of the Great Depression Wartime demand, however, caused increased commodity prices and massive inflation within the colony.
In 1954, Julius Nyerere transformed an organisation into the politically oriented Tanganyika African National Union (TANU). TANU's main objective was to achieve national sovereignty for Tanganyika. A campaign to register new members was launched, and within a year, TANU had become the leading political organisation in the country. Nyerere became Minister of British-administered Tanganyika in 1960 and continued as prime minister when Tanganyika became independent in 1961.
British rule came to an end on December 9, 1961, but for the first year of independence, Tanganyika had a governor general who represented the British monarch. On 9 December 1962, Tanganyika became a democratic republic under an executive president.
After the Zanzibar Revolution overthrew the Arab dynasty in neighbouring Zanzibar, which had become independent in 1963, the archipelago merged with mainland Tanganyika on 26 April 1964. On 29 October of the same year, the country was renamed the United Republic of Tanzania ("Tan" comes from Tanganyika and "Zan" from Zanzibar). The union of the two hitherto separate regions was controversial among many Zanzibaris (even those sympathetic to the revolution) but was accepted by both the Nyerere government and the Revolutionary Government of Zanzibar owing to shared political values and goals.
Following Tanganyika's independence and unification with Zanzibar leading to the state of Tanzania, President Nyerere emphasized a need to construct a national identity for the citizens of the new country. To achieve this, Nyerere provided what is regarded as one of the most successful cases of ethnic repression and identity transformation in Africa. With over 130 languages spoken within its territory, Tanzania is one of the most ethnically diverse countries in Africa. Despite this obstacle, ethnic divisions remained rare in Tanzania when compared to the rest of the continent, notably its immediate neighbor, Kenya. Furthermore, since its independence, Tanzania has displayed more political stability than most African countries, particularly due to Nyerere's ethnic repression methods.
In 1967, Nyerere's first presidency took a turn to the left after the Arusha Declaration, which codified a commitment to socialism as well-as Pan-Africanism. After the declaration, banks and many large industries were nationalised.
Tanzania was also aligned with China, which from 1970 to 1975 financed and helped build the 1,860-kilometre-long (1,160 mi) TAZARA Railway from Dar es Salaam to Zambia. Nonetheless, from the late 1970s, Tanzania's economy took a turn for the worse, in the context of an international economic crisis affecting both developed and developing economies.
From the mid-1980s, the regime financed itself by borrowing from the International Monetary Fund and underwent some reforms. Since then, Tanzania's gross domestic product per capita has grown and poverty has been reduced, according to a report by the World Bank.
In 1992, the Constitution of Tanzania was amended to allow multiple political parties. In Tanzania's first multi-party elections, held in 1995, the ruling Chama Cha Mapinduzi won 186 of the 232 elected seats in the National Assembly, and Benjamin Mkapa was elected as president.