Walvis Bay was the only decent deep water port on the South West African coast. As such, the Royal Navy took an interest in the port and were worried about it falling into their rivals hands. The port was annexed in 1878. This was a period of expansion for the British in Southern Africa. They had recently taken control of the Transvaal and were about to embark on a war in Zululand
In 1884 the port became part of the Cape Colony. Again, the British were reacting to the German moves in the area and their annexation of South West Africa. South West Africa was was little more than arid desert and the German colony struggled. There were disputes over the exact borders of the Walvis Bay colony. These were not resolved until 1911.
In 1910 the Cape Colony, and therefore Walvis Bay, joined the new Union of South Africa despite its physical separation from the Union.
World War One would bring Walvis Bay into the firing line as forces from South Africa moved into South West Africa in what was to become a difficult campaign over dry desert. The campaign came to a successful conclusion in 1915. At the end of the war South West Africa became a League of Nations Mandate that was to be governed by South Africa. Administratively, it made sense to transfer Walvis Bay to this mandate which was done in 1922.