There are over 120 tribes on the mainland, most of which migrated from other parts of Africa over the millennia, whilst on the coast, the Swahili people originated from an eclectic mix of traders – Arabic, Persian and Chinese among others – who arrived from as early as the 8th century.
The first European arrival was the Portuguese explorer, Vasco da Gama, who visited the coast in the late-15th century, after which most of the littoral region came under Portuguese control. The Portuguese also controlled Zanzibar until 1699, when they were ousted from the island by Omani Arabs. In the late-19th century, along with Rwanda and Burundi, Tanganyika was absorbed into the colony of German East Africa, and was a fairly quiet part of the German empire until the end of WWI. Then, following the German defeat, it was administered by the British under successive League of Nations and United Nations mandates. Tanganyika became independent within the Commonwealth in 1961, under charismatic leader, Julius Nyerere, who was President until 1985. In 1964, Tanganyika joined with Zanzibar and became Tanzania. Prior to that, Zanzibar had been a British protectorate and an independent sultanate.
From Independence, Chama Cha Mapinduzi (CCM, Revolutionary Party of Tanzania), was the ruling party, as it still is today. Nyerere's initial main objective was the application of socialist principles (based on the Chinese communist model) to an African agricultural society and economy. The CCM nationalised industries and established an agricultural collective system known as Ujamaa, where people were grouped into self-sufficient villages. But mismanagement and external events conspired to wreck Nyerere's plans, with dire consequences for the economy and by 1977 Ujamaa was abandoned.
Tanzania proved itself an active player in regional politics, by giving support to anti-Apartheid movements in South Africa, and it intervened militarily in Uganda in 1979, to overthrow the Amin regime. Tanzania was a founder member of the Southern African Development Co-ordination Conference and has been a prominent participant in the Organisation of African Unity.
In 1985, Nyerere retired and was replaced as President by Ali Hassan Mwinyi, who introduced market forces into the economy and on the political front, amendments to the constitution allowing for the introduction of a multiparty system. Nevertheless, the CCM comfortably won the 1995 elections, when Benjamin Mkapa became President. In August 1998, Tanzania was the scene of a major terrorist incident when the US embassy in Dar es Salaam was bombed (a simultaneous explosion occurred in Nairobi). October 1999 was marked by the death of ex-president Julius Nyerere, whose funeral drew senior representatives from almost every government in the world.
Mkapa won a further term of office at the end of 2000 but there were vote rigging and intimidation allegations, particularly on Zanzibar. Again in the 2005 election, Zanzibar experienced tension and some violence when the CCM candidate was declared the winner, but results were disputed with claims that the candidate of the Civic United Front (CUF) won the majority of votes. Some CUF members were calling for Zanzibar’s complete independence and these incidents served to underscore what many perceive as a drive for autonomy amongst some islanders. However, negotiations in 2009 were hailed as a breakthrough, and elections in 2010 were peaceful following the approval of a power-sharing agreement between the CCM and CUF. Since then, Zanzibar has been administered by a unity government under President Ali Mohamed Shein.
Nationwide presidential elections were won by the CCM under President Jakaya Kikwete in 2005 and again in 2010. Kikwete previously spent 10 years as foreign minister.