The military history of South Africa chronicles a vast time period and complex events from the dawn of history until the present time. It covers civil wars and wars of aggression and of self-defence both within South Africa and against it. It includes the history of battles fought in the territories of modern South Africa in neighboring territories, in both world wars and in modern international conflicts.
The arrival of the permanent settlements of the Dutch East India Company at the Cape of Good Hope in 1652 brought them face to face with the local people, such as the Khoikhoi (called Hottentots by the Dutch), the San (Bushmen) and some Bantu peoples of South Africa. While the Dutch traded with the Khoikhoi, nevertheless serious disputes broke out over land ownership and livestock. This resulted in attacks and counter-attacks by both sides which were known as the Khoikhoi-Dutch Wars. The First Khoikhoi-Dutch War took place in 1659, the second in 1673 and the third in 1674–1677.
During 1664, tensions between Britain and the Netherlands rose with rumours of war being imminent — that same year, Commander Zacharius Wagenaer was instructed to build a pentagonal castle out of stone at 33°55′33″S 18°25′40″E / 33.925806°S 18.427758°E. On 26 April 1679, the five bastions were built. The Castle of Good Hope is a fortification which was built on the original coastline of Table Bay and now, because of land reclamation, seems nearer the centre of Cape Town, South Africa. Built by the VOC between 1666 and 1679, the Castle is the oldest building in South Africa. The Castle acted as local headquarters for the South African Army in the Western Cape, but today houses the Castle Military Museum and ceremonial facilities for the traditional Cape Regiments.