The United Republic of Tanzania emerged on April 26, 1964, through the union of Tanganyika and Zanzibar, creating a single nation from two distinct political entities. Tanganyika achieved independence from Britain on December 9, 1961, under Julius Nyerere, who became the country's first Prime Minister and subsequently its first President when the nation became a republic on December 9, 1962. Zanzibar obtained independence from Britain on December 10, 1963, but the sultanate lasted only 33 days before the Zanzibar Revolution of January 12, 1964, overthrew Sultan Jamshid bin Abdullah and established a revolutionary government under Abeid Karume. The subsequent union created a federated structure where Zanzibar maintains its own president, legislature, and judicial system while sharing defense, foreign affairs, and certain economic policies with the mainland.
Human settlement in what is now Tanzania extends beyond two million years. Olduvai Gorge in the Ngorongoro Conservation Area yielded fossils that redefined understanding of human evolution when Mary Leakey discovered the skull of Paranthropus boisei in 1959, dated to approximately 1.8 million years ago. Her husband Louis Leakey had been excavating the site since 1931. In 1978, Mary Leakey discovered hominin footprints at Laetoli, 45 kilometers south of Olduvai Gorge, preserved in volcanic ash and dated to 3.66 million years ago. These footprints demonstrated bipedal locomotion in Australopithecus afarensis. The Kondoa Rock Art Sites contain paintings spanning approximately 50,000 years, with the oldest attributed to hunter-gatherer communities and later additions from pastoralist and agricultural societies.
Bantu-speaking populations migrated into the region from the west and northwest between 1000 BCE and 500 CE, introducing ironworking and agricultural practices. These migrations displaced or absorbed earlier hunter-gatherer groups, whose descendants include the Hadza people of the Lake Eyasi region and the Sandawe of central Tanzania. The Hadza number approximately 1,200 individuals as of recent surveys, maintain a hunter-gatherer lifestyle, and speak a language with click consonants unrelated to Bantu languages. Linguistic analysis identifies over 120 languages spoken in Tanzania today, belonging primarily to the Bantu family, with additional Nilotic languages in the north and Cushitic languages in isolated pockets.
The Swahili city-states developed along the East African coast and islands between the 8th and 15th centuries, serving as commercial intermediaries between the African interior and the Indian Ocean trade networks. Kilwa Kisiwani, located on an island off southern Tanzania, became one of the most powerful city-states by the 13th century. The Kilwa Chronicle, a historical text compiled from oral traditions, attributes the founding of Kilwa to Ali ibn al-Hassan Shirazi in approximately 957 CE, though archaeological evidence suggests continuous settlement beginning around 800 CE. Kilwa minted its own coins, the earliest found dated to the reign of Sultan Ali ibn al-Hassan in the 11th century. The Great Mosque of Kilwa, constructed in phases between the 11th and 15th centuries, featured a domed ceiling supported by barrel vaults, representing sophisticated architectural engineering for the period. The Portuguese navigator Vasco da Gama visited Kilwa in 1502 during his second voyage to India. The Portuguese established control over Kilwa in 1505 under Francisco de Almeida, constructing a fort whose ruins remain visible.
Omani Arabs contested Portuguese coastal dominance throughout the 17th century. The Omani Yarubi dynasty expelled Portuguese forces from Fort Jesus in Mombasa in 1698 after a siege lasting from 1696. Omani influence over the Swahili coast expanded under the Busaidi dynasty, particularly after Sultan Seyyid Said relocated his capital from Muscat to Zanzibar in 1840. This relocation transformed Zanzibar into the commercial center for East African trade in cloves, ivory, and enslaved people. Clove cultivation, introduced to Zanzibar from Mauritius in 1818 by Saleh bin Haramil al-Abray, expanded rapidly under Omani plantation systems. By the 1850s, Zanzibar produced approximately three-quarters of the world's cloves. The trade in enslaved people from the interior reached an estimated 50,000 individuals annually by the 1860s, passing through Zanzibar's markets before export to Oman, the Persian Gulf, and Indian Ocean islands.
Explorers dispatched by European geographical societies traveled through Tanzanian territory in the mid-19th century seeking the source of the Nile. Richard Burton and John Hanning Speke reached Lake Tanganyika in February 1858. Speke continued north alone and reached Lake Victoria in August 1858, which he proposed as the Nile's source, a claim Burton disputed. Speke returned with James Grant in 1862, departing from Zanzibar in October 1860, and reached the Ripon Falls where the Victoria Nile exits Lake Victoria on July 28, 1862. David Livingstone, the Scottish missionary and explorer, disappeared in the interior while searching for the Nile's source. Henry Morton Stanley, dispatched by the New York Herald, located Livingstone at Ujiji on the shore of Lake Tanganyika on November 10, 1871, reportedly greeting him with the phrase preserved in journalistic accounts. Livingstone died on May 1, 1873, at Chitambo in present-day Zambia. His companions Susi and Chuma carried his body to Bagamoyo on the Tanzanian coast, from where it was shipped to Britain for burial in Westminster Abbey.
German colonization of mainland Tanzania began through Carl Peters and the Society for German Colonization, which signed treaties with local chiefs in the Usagara, Nguru, and Useguha regions in 1884. The German government declared a protectorate over these territories in February 1885, formalized as German East Africa after the Berlin Conference of 1884-1885, which partitioned African territories among European powers. The Anglo-German Agreement of 1886 and subsequent treaties with the Sultan of Zanzibar defined boundaries, with Zanzibar and Pemba becoming a British protectorate in 1890 in exchange for German recognition of British claims to Heligoland in the North Sea. German colonial administration introduced plantation agriculture, particularly sisal and rubber, and constructed the Central Railway from Dar es Salaam to Kigoma on Lake Tanganyika between 1905 and 1914.
The Maji Maji Rebellion occurred between 1905 and 1907 across southern and central German East Africa. The immediate trigger involved cotton cultivation mandates imposed by German authorities under a tax system that required forced labor. Kinjikitile Ngwale, a spirit medium in the Matumbi Hills, distributed water he claimed would turn German bullets into water, the meaning of "maji" in Swahili. The rebellion began in July 1905 when groups attacked German trading posts and missions. German forces under Governor Gustav Adolf von Götzen responded with scorched-earth tactics, burning villages and food stores. The rebellion's suppression resulted in an estimated 75,000 to 300,000 deaths, primarily from famine caused by the destruction of crops. Kinjikitile was captured and hanged in August 1905.
Chief Mkwawa of the Hehe people led resistance against German expansion in the central highlands. The Hehe defeated a German military expedition at the Battle of Lugalo on August 17, 1891, killing approximately 300 askari soldiers and German officers. Mkwawa conducted guerrilla warfare from his fortified settlement at Kalenga until German forces captured it in October 1894. He evaded capture until June 19, 1898, when, surrounded by German troops, he shot himself to avoid capture. German officers took his skull to Germany as a trophy. The skull was returned to Tanzania in 1954 after years of negotiation and is displayed at the Mkwawa Memorial Museum in Kalenga.