The Cape Colony (Kaapkolonie), also known as the Cape of Good Hope, was a British colony in present-day South Africa named after the Cape of Good Hope. It existed from 1795 to 1802, and again from 1806 to 1910, when it united with three other colonies to form the Union of South Africa, then became the Cape Province, which existed even after 1961, when South Africa had become a republic, albeit, temporarily outside the Commonwealth of Nations (1961-94).
The British colony was preceded by an earlier corporate colony that became an original Dutch colony of the same name, which was established in 1652 by the Dutch East India Company (VOC). The Cape was under VOC rule from 1652 to 1795 and under rule of the Napoleonic Batavia Republic from 1803 to 1806. The VOC lost the colony to Great Britain following the 1795 Battle of Muizenberg, but it was acceded to the Batavia Republic following the 1802 Treaty of Amiens. It was re-occupied by the British following the Battle of Blaauwberg in 1806, and British possession affirmed with the Anglo-Dutch Treaty of 1814. The Cape of Good Hope then remained in the British Empire, becoming self-governing in 1872.
The colony was coextensive with the later Cape Province, stretching from the Atlantic coast inland and eastward along the southern coast, constituting about half of modern South Africa: the final eastern boundary, after several wars against the Xhosa, stood at the Fish River. In the north, the Orange River, natively known as the ǂNūǃarib (Black River) and subsequently called the Gariep River, served as the boundary for some time, although some land between the river and the southern boundary of Botswana was later added to it. From 1878, the colony also included the enclave of Walvis Bay and the Penguin Islands, both in what is now Namibia.
It united with three other colonies to form the Union of South Africa in 1910, and was accordingly renamed the Province of the Cape of Good Hope. South Africa became a sovereign state in 1931 by the Statute of Westminster.