During the Napoleonic Wars, the Cape Colony was annexed by the British and officially became their colony in 1815. Britain encouraged settlers to the Cape, and in particular, sponsored the 1820 Settlers to farm in the disputed area between the colony and the Xhosa in what is now the Eastern Cape. The changing image of the Cape from Dutch to British excluded the Dutch farmers in the area, the Boers who in the 1820s started their Great Trek to the northern areas of modern South Africa. This period also marked the rise in power of the Zulu under their king Shaka. Subsequently, several conflicts arose between the British, Boers and Zulus, which led to the Zulu defeat and the ultimate Boer defeat in the Second Anglo-Boer War. However, the Treaty of Vereeniging established the framework of South African limited independence as the Union of South Africa.

British Colonisation At the tip of the continent, the British found an established colony with 25,000 slaves, 20,000 white colonists, 15,000 Khoisan, and 1,000 freed black slaves. Power resided solely with a white élite in Cape Town, and differentiation on the basis of race was deeply entrenched. Outside Cape Town and the immediate hinterland, isolated black and white pastoralists populated the country.

Like the Dutch before them, the British initially had little interest in the Cape Colony, other than as a strategically located port. As one of their first tasks they tried to resolve a troublesome border dispute between the Boers and the Xhosa on the colony's eastern frontier. In 1820 the British authorities persuaded about 5,000 middle-class British immigrants (most of them "in trade") to leave England behind and settle on tracts of land between the feuding groups with the idea of providing a buffer zone. The plan was singularly unsuccessful. Within three years, almost half of these 1820 Settlers had retreated to the towns, notably Grahamstown and Port Elizabeth, to pursue the jobs they had held in Britain.

While doing nothing to resolve the border dispute, this influx of settlers solidified the British presence in the area, thus fracturing the relative unity of white South Africa. Where the Boers and their ideas had before gone largely unchallenged, European Southern Africa now had two language groups and two cultures. A pattern soon emerged whereby English-speakers became highly urbanised, and dominated politics, trade, finance, mining, and manufacturing, while the largely uneducated Boers remained on their farms.

The gap between the British settlers and the Boers further widened with the abolition of slavery in 1833, not because the slaves were freed, but the way in which they were freed (compensation for freed slaves, for example, had to be fetched personally in London). Yet the British settlers' conservatism and sense of racial superiority stopped any radical social reforms, and in 1841 the authorities passed a Masters and Servants Ordinance, which perpetuated white control. Meanwhile, British numbers increased rapidly in Cape Town, in the area east of the Cape Colony (present-day Eastern Cape Province), in Natal and, after the discovery of gold and diamonds, in parts of the Transvaal, mainly around present-day Gauteng.

Difaqane and destruction

The early 19th century saw a time of immense upheaval relating to the military expansion of the Zulu kingdom. Sotho-speakers know this period as the difaqane ("forced migration"); while Zulu-speakers call it the mfecane ("crushing").

The full causes of the difaqane remain in dispute, although certain factors stand out. The rise of a unified Zulu kingdom had particular significance. In the early 19th century, Nguni tribes in KwaZulu-Natal began to shift from a loosely organised collection of kingdoms into a centralised, militaristic state. Shaka Zulu, son of the chief of the small Zulu clan, became the driving force behind this shift. At first something of an outcast, Shaka proved himself in battle and gradually succeeded in consolidating power in his own hands. He built large armies, breaking from clan tradition by placing the armies under the control of his own officers rather than of the hereditary chiefs. Shaka then set out on a massive programme of expansion, killing or enslaving those who resisted in the territories he conquered. His impis (warrior regiments) were rigorously disciplined: failure in battle meant death.

Peoples in the path of Shaka's armies moved out of his way, becoming in their turn aggressors against their neighbours. This wave of displacement spread throughout Southern Africa and beyond. It also accelerated the formation of several states, notably those of the Sotho (present-day Lesotho) and of the Swazi (now Swaziland).

In 1828 Shaka was killed by his half-brothers Dingaan and Umthlangana. The weaker and less-skilled Dingaan became king, relaxing military discipline while continuing the despotism. Dingaan also attempted to establish relations with the British traders on the Natal coast, but events had started to unfold that would see the demise of Zulu independence.

The Great Trek

Meanwhile, the Boers had started to grow increasingly dissatisfied with British rule in the Cape Colony. Various factors contributed to the migration, summarised in the Voortrekker leader, Piet Retief's manifesto. Beginning in 1835, several groups of Boers, together with large numbers of Khoikhoi and black servants, decided to trek off into the interior in search of greater independence. North and east of the Orange River (which formed the Cape Colony's frontier) these Boers or Voortrekkers ("Pioneers") found vast tracts of apparently uninhabited grazing lands. They had, it seemed, entered their promised land, with space enough for their cattle to graze and their culture of anti-urban independence to flourish. Little did they know that what they found – deserted pasture lands, disorganised bands of refugees, and tales of brutality – resulted from the difaqane, rather than representing the normal state of affairs.

With the exception of the more powerful Ndebele, the Voortrekkers encountered little resistance among the scattered peoples of the plains. The difaqane had dispersed them, and the remnants lacked horses and firearms. Their weakened condition also solidified the Boers' belief that European occupation meant the coming of civilization to a savage land. However, the mountains where King Moshoeshoe I had started to forge the Basotho nation that would later become Lesotho and the wooded valleys of Zululand proved a more difficult proposition. Here the Boers met strong resistance, and their incursions set off a series of skirmishes, squabbles, and flimsy treaties that would litter the next 50 years of increasing white domination.

British vs. Boers vs. Zulus

The Great Trek first halted at Thaba Nchu, near present-day Bloemfontein, where the trekkers established a republic. Following disagreements among their leadership, the various Voortrekker groups split apart. While some headed north, most crossed the Drakensberg into Natal with the idea of establishing a republic there. Since the Zulus controlled this territory, the Voortrekker leader Piet Retief paid a visit to King Dingaan, negotiating a contract by which certain regions of land would be awarded to the Voortrekkers in exchange for the reclaim of cattle that was allegedly stolen from the Zulu by the Tlokwa of Chief Sekonyela who lived west of the Drakensberg. However, once the cattle was retrieved and brought to Dingaan, he ordered the killing of all present (and unarmed) Voortrekkers under the guise of a farewell party. This killing triggered other attacks by Zulus on the Boer population, and a revenge attack by the Boers. The culmination came on 16 December 1838, in the Battle of Blood River, fought at the Ncome River in Natal. Though several Boers suffered injuries, they managed to overcome the Zulu attack, in which they were vastly outnumbered (464 Boere to an estimated 30 000 Zulus), without suffering a single death.

Following this victory, however, the Boers' hopes for establishing a Natal republic was short lived. The British annexed the area in 1843, and founded their new Natal colony at present-day Durban. The British set about establishing large sugar plantations in Natal, but found few inhabitants of the neighbouring Zulu areas willing to provide labour. The British confronted stiff resistance to their encroachments from the Zulus, a nation with well-established traditions of waging war, who inflicted one of the most humiliating defeats on the British army at the Battle of Isandlwana in 1879, where over 1400 British soldiers were killed. During the ongoing Anglo-Zulu Wars, the British eventually established their control over what was then named Zululand, and is today known as KwaZulu-Natal.

The British turned to India to resolve their labour shortage, as Zulu men refused to adopt the servile position of labourers and in 1860 the SS Truro arrived in Durban harbour with over 300 people on board. Over the next 50 years, 150,000 more indentured Indians arrived, as well as numerous free "passenger Indians", building the base for what would become the largest Indian community outside of India. As early as 1893, when Mahatma Gandhi arrived in Durban, Indians outnumbered whites in Natal. (See Indian South Africans.)

Growth of independent South Africa

The Boer republics

The Boers meanwhile persevered with their search for land and freedom, ultimately establishing themselves in various Boer Republics, e.g. the Transvaal or South African Republic and the Orange Free State. For a while it seemed that these republics would develop into stable states, despite having thinly spread populations of fiercely independent Boers, no industry, and minimal agriculture. The discovery of diamonds near Kimberley turned the Boers' world on its head (1869). The first diamonds came from land belonging to the Griqua, but to which both the Transvaal and Orange Free State laid claim. Britain quickly stepped in and annexed the area for itself.

The discovery of the Kimberley diamond-mines unleashed a flood of European and black labourers into the area. Towns sprang up in which the inhabitants ignored the "proper" separation of whites and blacks, and the Boers expressed anger that their impoverished republics had missed out on the economic benefits of the mines.

The Anglo-Boer Wars

First Anglo-Boer War

Long-standing Boer resentment turned into full-blown rebellion in the Transvaal (under British control from 1877), and the first Anglo-Boer War, known to Afrikaners as the "War of Independence", broke out in 1880. The conflict ended almost as soon as it began with a crushing Boer victory at Battle of Majuba Hill (27 February 1881). The republic regained its independence as the Zuid-Afrikaansche Republiek ("South African Republic"), or ZAR. Paul Kruger, one of the leaders of the uprising, became President of the ZAR in 1883. Meanwhile, the British, who viewed their defeat at Majuba as an aberration, forged ahead with their desire to federate the Southern African colonies and republics. They saw this as the best way to come to terms with the fact of a white Afrikaner majority, as well as to promote their larger strategic interests in the area.

Inter-war period

In 1879, Zululand came under British control. Then in 1886, an Australian prospector discovered gold in the Witwatersrand, accelerating the federation process and dealing the Boers yet another blow. Johannesburg's population exploded to about 100,000 by the mid-1890s, and the ZAR suddenly found itself hosting thousands of uitlanders, both black and white, with the Boers squeezed to the sidelines. The influx of English labour in particular worried the Boers, many of whom resented the English miners.