The leader of Zanzibar's revolution was a Ugandan called John Okello who had been living in Pemba. The local African population supported Okello with great enthusiasm, and went on a rampage through the islands, during which more than 17,000 Arabs and Indians were killed in one night. The leader of the Afro-Shirazi party, Sheik Abied Amani Karume, was installed as president of the newly proclaimed people's republic of Zanzibar, which included the islands of Unguja and Pemba.
Karume and other prominent ASP members formed the Revolutionary Government of Zanzibar (Serikali ya Mapinduzi ya Zanzibar, or SMZ). Most of Zanzibar's Asian and Indian people left the islands; their property was confiscated and their land nationalised. (On the mainland Sultan Jamshid was given temporary asylum in Dar es Salaam, then went to Britain where he lived in exile.)
Meanwhile, Tanganyika had also become independent in December 1961, with Julius Nyerere elected as president the following year. Nyerere had known and supported Karume since the mid-1950s but the Zanzibar Revolution created problems in Tanganyika, inspiring an attempted coup in Dar es Salaam only a few days later. (To suppress this coup Nyerere received help from Britain in the form of a battalion of commandos.)
Once Nyerere had regained control he approached Karume to discuss a political union, and on 24 April 1964 the two countries joined to form the United Republic of Tanganyika and Zanzibar. In October the same year the country was renamed Tanzania (from 'Tan' in Tanganyika and 'Zan' in Zanzibar). Nyerere became the president of the new state while Karume became vice-president. The SMZ was to control all local affairs on the islands of Unguja and Pemba, while foreign affairs would be handled by the Tanzanian government.
(During the negotiations John Okello had gone to the mainland to meet Nyerere. On his return to Zanzibar in March 1964 he was sent back to Dar es Salaam. He made no further public appearances.)
Despite the so-called union Karume kept Zanzibar separate from the rest of Tanzania in many respects. The clove plantations on Unguja and Pemba were developed and the earnings from exports continued to increase, but this revenue was not shared with mainland Tanzania.
After the revolution almost all the European and Asian residents had left Zanzibar. To fill the vacuum caused by the departure of these skilled people Karume attracted technical and military assistance from Cuba, China and the then Eastern bloc countries of East Germany, Bulgaria and the Soviet Union. Engineers from East Germany designed and built new blocks of flats in Zanzibar Town, and in 'new towns' elsewhere on the islands of Unguja and Pemba. In 1970 Karume's government was accused of human rights violations against political opponents.
On 7 April 1972 Karume was assassinated while playing cards in the ASP headquarters in Zanzibar Town. Aboud Jumbe Mwinyi, who had been a member of the ASP since before independence, became the new leader of the Revolutionary Government. Mwinyi was less hardline than Karume and introduced several reforms. He was also more sympathetic towards Nyerere and mainland Tanzania. In February 1977 the ASP united with Nyerere's party, the Tanzania African National Union (TANU), to form the Chama Cha Mapinduzi (Party of the Revolution).
After this unification, both leaders began to relax some of their policies on nationalised industries and state financial control. Relations with some Western nations, including Britain, slowly improved. In July 1979, as a sign that Tanzania was regaining some international respect, Queen Elizabeth II of the UK visited Zanzibar. Then, in 1980, the first presidential elections took place, and Aboud Jumbe Mwinyi was officially elected as president of Zanzibar.