After the Second World War, the mandate was transformed into a United Nations Trust Administration (December 13, 1946). The constitutional reforms of 1948 and 1954 favored the political evolution of Tanganyika and the birth of a nationalism that found in J. Nyerere and the Tanganyika African National Union (TANU) moderate but effective support. In agreement with the UN, England first granted internal autonomy to Tanganyika (1 May 1961) and then full independence (9 December 1961). Tanganyika, which entered the Commonwealth as a monarchy linked to the British crown, opted on 9 December 1962 for the republican form of government with Nyerere as president. In December 1963, Zanzibar and Pemba also achieved independence and in April 1964 the integration of the two countries was achieved following an agreement between the two presidents, Nyerere and Abeid Karume, who became respectively president and vice president of the United Republic of Tanzania. On 1 October 1964 the Constitution was promulgated ad interim of the United Republic of Tanzania, completed by an annex reproducing the Statute of the TANU, that is the single party that formed the basis of Tanzanian socialism. The latter found its programmatic formulation in the Arusha declaration of 1967. In the 1970s the contrasts between Tanzania, Uganda and Kenya caused the dissolution of the East African Community (1977), which had been the common economic and political basis of the aforementioned countries.
According to getzipcodes, the contrasts subsequently worsened between Tanzania and Uganda, leading to a real conflict (1978-79) which ended with the defeat of the Ugandan army by the Tanzanian forces. In 1985 J. Nyerere resigned from the presidency of the Republic (after having remained in office for 24 years) but remained at the helm of the Chama Cha Mapinduzi (CCM, Party of the Revolution), single party born in 1977 from the merger of TANU and ASP (Afro-Shirazi Party, operating in Zanzibar). The new head of state, Ali Hassan Mwinyi, a prompt promoter of economic liberalization measures and a recovery plan, was harshly criticized by J. Nyerere who, reconfirmed in 1987 as head of the CCM for a five-year term, resigned in 1990. The political (and economic transition in the liberal sense) started in 1985 ended with the reunification of the two offices in the hands of AH Mwinyi who in 1990 won the presidential elections and brought his supporters to the top of state institutions. The beginning of the nineties saw the extension of liberalization from the economic level to the political one, sanctioned by the formal recognition of the multi-party system by the extraordinary conference of the CCM (February 1992), also engaged in an effort of internal democratization. This did not, however, lead to new elections: the opposition remained divided and failed to organize itself in a coalition that included the movements active in the islands of Pemba and Zanzibar, where separatist tendencies continued to manifest. To mitigate the autonomist ferments, the National Assembly approved (1993) a resolution which extended the wide autonomy already foreseen for Zanzibar to Tanganyika as well.
In November 1994 the CCM obtained a landslide victory in the first multi-party administrative elections: President AH Mwinyi appointed Cleopa Msuya as Prime Minister, receiving the favorable vote of the National Assembly. In the’ October 1995 the first multi-party presidential and legislative elections were finally held, but the opposition immediately asked for the annulment, denouncing fraud and irregularities in favor of the government candidates. However, Benjamin Mkapa (CCM) was elected to the presidency of the republic; the CCM also managed to win an absolute majority of seats in the National Assembly, while its victory in the elections of the House of Representatives held at the same time in Zanzibar was much less clear: this provoked the wide protests of the leader of the opposition party CUF (Front United Civic). In November, President B. Mkapa was able to form the new government, entrusting the office of prime minister to Frederick Sumaye. The CCM also established itself in the 2000 elections, which again confirmed B. Mkapa as president. In Zanzibar, however, the elections were canceled due to serious irregularities; a demonstration organized by the CUF and declared illegal by the CCM took place on the island in 2001 to ask for a repeat of the elections and caused violent clashes with ca. 200 dead and many injured. In order to end the political violence, CCM and CUF signed an agreement negotiating a long-term solution to the crisis. Also in 2001, Tanzania signed an agreement with Malawi to resolve a long dispute regarding the border on the Songwe River and also on the international level, in March 2004, the Tanzanian government signed a preliminary agreement with Kenya and Uganda for the creation of a union. customs. In 2005, legislative elections were held: B. Jakaya Kikwete who with 80% of the votes was appointed president. The CCM therefore continued to control the political life of the country with an overwhelming majority, while guaranteeing compliance with democratic rules. In October 2010, the outgoing president won the presidential elections with over 60% of the vote. In 2015 he was replaced by another member of the CCM, John Magufuli, reconfirmed in the office in 2020. Following the death of John Magufuli, which occurred on March 17, 2021, the presidency was assumed on March 19 of the same year by Samia Suluhu, formerly vice president of Magafuli.