By 1850 European explorers had begun mapping the interior. Three developments encouraged European interest in East Africa in the first half of the nineteenth century. First, was the emergence of the island of Zanzibar, located off the east coast of Africa. Zanzibar became a base from which trade and exploration of the African mainland could be mounted. By 1840, to protect the interests of the various nationals doing business in Zanzibar, consul offices had been opened by the British, French, Germans and Americans. In 1859, the tonnage of foreign shipping calling at Zanzibar had reached 19,000 tons.[11] By 1879, the tonnage of this shipping had reached 89,000 tons. The second development spurring European interest in Africa was the growing European demand for products of Africa including ivory and cloves. Thirdly, British interest in East Africa was first stimulated by their desire to abolish the slave trade. Later in the century, British interest in East Africa would be stimulated by German competition, and in 1887 the Imperial British East Africa Company, a private concern, leased from Seyyid Said his mainland holdings, a 10-mile (16-km)-wide strip of land along the coast.
In 1895 the British government took over and claimed the interior as far west as Lake Naivasha; it set up the East Africa Protectorate. The border was extended to Uganda in 1902, and in 1920 the enlarged protectorate, except for the original coastal strip, which remained a protectorate, became a crown colony. With the beginning of colonial rule in 1895, the Rift Valley and the surrounding Highlands became the enclave of white immigrants engaged in large-scale coffee farming dependent on mostly Kikuyu labour.
As a reaction to their exclusion from political representation, the Kikuyu people, the most subject to pressure by the settlers, founded in 1921 Kenya's first African political protest movement, the Young Kikuyu Association, led by Harry Thuku. After the Young Kikuyu Association was banned by the government, it was replaced by the Kikuyu Central Association in 1924.
In 1944 Thuku founded and was first chairman of the multi-tribal Kenya African Study Union (KASU), which in 1946 became the Kenya African Union (KAU). It was an African nationalist organisation that demanded access to white-owned land.
A key watershed came from 1952 to 1956, during the Mau Mau Uprising, an armed local movement directed principally against the colonial government and the European settlers. It was the largest and most successful such movement in British Africa, but it was not emulated by the other colonies. The protest was supported almost exclusively by the Kikuyu, despite issues of land rights and anti-European, anti-Western appeals designed to attract other groups. The British killed over 4000, and the Mau Mau many more, as the assassinations and killings on all sides reflecting the ferocity of the movement and the ruthlessness with which the British suppressed it. (These numbers are disputed, estimates for the number of Kikuyu dead range as high as 300,000.)
In 1962 a KANU-KADU coalition government, including both Kenyatta and Ngala, was formed. Kenya now achieved internal self-government with Jomo Kenyatta as its first prime minister. The British and KANU agreed, over KADU protests, to constitutional changes in October 1963 strengthening the central government. Kenya attained independence on 12 Dec 1963 as a commonwealth realm with HM The Queen as Head of State. (1963 Constitution of Kenya). In 1964 Kenya became a republic, and constitutional changes further centralised the government.
The British government bought out the white settlers and they mostly left Kenya. The Indian minority dominated retail business in the cities and most towns, but was deeply distrusted by the Africans. As a result 120,000 of the 176,000 Indians kept their old British passports rather than become citizens of an independent Kenya; large numbers left Kenya, most of them headed to Britain.