During the colonial occupation of Kenya, Black Africans working on farms owned by white settlers were called "squatters" by the British. As of 1945, there were over 200,000 such squatters in the Highlands and more than half were Kikuyu. The Mau Mau rebellion began amongst these squatters in the late 1940s and after independence in the early 1960s, peasants started squatting land in rural areas without the permission of the owner. 
 In recent years, community groups including indigenous peoples and squatters have challenged agricultural companies over land they regard as belonging to them following the foundation of the National Land Commission. In 2007, 55 per cent of Kenya's urban population lived in slums, in which people either owned, rented or squatted their houses and as of 2019, 4.39 million people lived in the capital Nairobi, with around half living in informal settlements such as Huruma, Kibera and Mathare.
 The Kenyan part of the East Africa Protectorate became the Kenya Colony, a British Crown colony, in 1920. White settlers took 7 million acres (28,000 km2), including some of the most fertile areas. This land was named the "White Highlands" and native peoples were moved into reserves.: 8  For example, the Kikuyu people had most of their land confiscated and by 1948, 1.25 million Kikuyus were confined to 1.3 million acres (5,300 km2) and 30,000 settlers occupied 7.7 million acres (31,000 km2).: 6  Kenyan labourers who worked for white settlers were permitted a small amount of land where they lived and grew food. By the 1920s, these labourers had become known as "squatters" by the British.: 172–173  A similar process occurred in Southern Rhodesia and South Africa; by World War I there were estimated to be 100,000 such squatters in Kenya. Some Kikuyu squatters moved to the Rift Valley because the land was more fertile than where they had previously lived and also settlers protected the men from conscription.: 13–14  The farmers grew pyrethrum and produced tea and coffee.: 81  Tabitha Kanogo argues in Squatters and the Roots of Mau Mau, 1905-63 that in the Rift Valley Province the settlers needed labourers and the squatters also wanted land to farm, so "each group needed to exploit the resources controlled by the other".: 8, 18  She notes that alongside the squatting system there was also illegal squatting and a system in which labourers paid the settlers to use their land; in 1910, there were 20,000 Kikuyu farmers of the latter type. During World War I, the labourers maintained the farms on behalf of the settlers.: 15–16 
 The 1918 Resident Native Labourers Ordinance was brought in as an attempt to regulate illegal squatting and to control labourers, with measures such as the restriction of labourers paying to farm land they did not own and the insistence that labourers must work at least 180 days in the year at a specific farm.: 25, 37  Labourers reacted by going on strike, leaving their jobs, engaging in sabotage and starting to squat illegally.: 36, 50  Settler attempts to control the squatters culminated in the 1937 Resident Native Labourers Ordinance, which stated squatters only had rights to live in the Highlands when allowed by a settler and enforced a limit on how much squatters could farm. Whilst World War II slowed its implementation, in the late 1940s its effects were felt and labourers were forced to organise in groups such as the Kikuyu Highlands Squatters Association.: 97, 98, 103 
 As of 1945, there were over 200,000 licensed squatters in the Highlands and over half were Kikuyu.: 126  Tensions between these squatters and the government continued to rise, and a flashpoint occurred when the government attempted to house displaced Kikuyu people in the Olenguruone settlement and the former squatters objected to being made into tenants.: 107–108  The Mau Mau rebellion began amongst squatters in the late 1940s and by September 1952, 412 people had been jailed for allegedly being part of the insurrection.: 136–137  The events led to a forced displacement of squatters from the Highlands to reserves and there was a period of armed struggle between 1952 and 1956.: 142, 162  
 The 1954 Swynnerton Plan recommended a new land registration scheme. After independence in the early 1960s, peasants started squatting land in rural areas in the centre of the country and on the coast. The Land Development and Settlement Board, founded in 1961, declared that Africans could now buy and farm land in the "White Highlands". From 1963 until 1978, squatters successfully resisted a World Bank funded forestation project in Turbo by settling lands and ripping out trees. They appealed to Jomo Kenyatta who was first Prime Minister and later President.
 The United Nations Department of Economic and Social Affairs (UN DESA) estimated in 2007 that 55 per cent of Kenya's urban population lived in slums, in which people either owned, rented or squatted their houses. As of 2019, 4.39 million people lived in the capital Nairobi and around half lived in informal settlements, occupying just 1 per cent of the city's land. Many slums (for example Huruma, Kibera and Mathare) were clustered in a belt around 4 km from the Central Business District. Research in 2020 using Geographic information system (GIS) technology suggested the population of Kibera was around 283,000, lower than mainstream media estimates; the United Nations Human Settlements Programme (UN-HABITAT) had previously estimated there to be between 350,000 and 1 million inhabitants. Mathare is a collection of squatted villages in the valley of the Mathare River, which were founded in the 1960s. 
 GIS analysis was also used to plot occupations in the Chyulu Hills, where squatters who want to farm the land have come into conflict with conservationists, who want to preserve it. This dispute has resulted in violent evictions by the Kenya Wildlife Service. In 2014, the government sent the military to the Embobut forest in order to evict over 15,000 Sengwer people from their own land. International groups such as Survival International and Forest Peoples Programme condemned the evictions, saying they were illegal and further that the government should not call the Sengwer squatters. In 2009, the government began to evict squatters from the Mau forest, citing concerns over the energy, tea and tourism industries. Conservationists had urged action to protect the whole Rift valley ecosystem from deforestation and water scarcity.
 Community groups including indigenous peoples and squatters have challenged agricultural companies such as Del Monte Kenya and Kakuzi Limited over land they regard as belonging to them following the foundation of the National Land Commission in 2012. The following year, the National Land Titling Programme was launched. In 2020, President Uhuru Kenyatta pledged to give two thirds of all Kenyans title to their land over the next two years. Land at Mikanjuni in Kilifi, Coast Province, was purchased by the state to give to 1,300 squatter families; Member of Parliament Gideon Mung'aro praised the initiative and commented that some squatters had been waiting 30 years to gain title to their land. By July 2022, the National Land Titling Programme intended to issue over one million titles in 42 counties.