As early as the 8th century AD, Zanzibar and other islands off the coast of East Africa became bases for Arab merchants trading with the mainland, which they called the Land of Zenj (Arabic, blacks), or Azania. In the course of time some of these including Zanzibar and Kilwa became independent Muslim sultanates with mixed Arab and African populations.
In the 16th and 17th centuries they were dominated by the Portuguese, and in the 18th century, Zanzibar and Pemba were subject to the sultans of Muscat and Oman. In 1832 the Omani sultan Sayyid Said (1787-1856) established his residence on Zanzibar, where he promoted the production of cloves and palm oil and carried on an active slave trade with the interior. His domain, which included parts of the mainland, was a commercial rather than a territorial empire. His successors did not have a legal claim to the lands they controlled commercially, and did not have the power to keep the Germans and British from annexing them when the European nations began dividing up Africa later in the century.
Zanzibar was declared a British protectorate in 1890; the sultan was
retained for ceremonial purposes, but most major decisions were made by
the British resident. Sultan Khalifa ibn Harub (1879-1960) used his influence
to support British rule. At the time of his death, Britain was divesting
itself of its African colonies, and Zanzibar, troubled by political factionalism,
was granted independence in December 1963. A few weeks later, January 12,
1964, its conservative government was overthrown in a bloody revolution
and replaced by a leftist regime under Sheikh Abeid Amani Karume (1905-72).
Immediately after the revolution, Karume signed a pact with Nyerere uniting
Zanzibar and Tanganyika to form The United Republic of Tanzania.