The conflict known variously as the South African Border War, the Namibian War of Independence, or the Angolan Bush War, was an incredibly complex, 23 year long struggle between South Africa, a well-established colonial state fighting a losing battle against majority rule, and the South West African People's Organization (SWAPO), a political party turned national liberation movement whose struggle was carried on by a relatively small number of insurgents. Both groups were supported by a number of other actors, falling as they did across the First World-Third World divide, as well as on either side of the Cold War, with the United States generally supporting South Africa and its proxies while the Soviet Union supported SWAPO with funding, supplies and military advisors.
The conflict was over the territory which comprises present-day Namibia, but back then as South West Africa. This former colony, previously mandated to South Africa by the League of Nations, had been incorporated as the country's fifth province after it refused to cede the territory to the newly formed United Nations in 1946. Following an International Court of Justice (ICJ) ruling that South Africa illegally controlled the territory of Namibia, SWAPO, now able to portray itself as the protagonist in an independence struggle against an unrepentant colonial power, carried out is first attack on South Africa on August 26, 1966.
While it was clear that for SWAPO that there was no going back once the conflict began, South Africa had a similarly all-or-nothing perspective on the conflict. For South Africa, the international situation was integral to its motivations for staying in the war. Not only was the UN seen as supporting SWAPO, both due to the majority of its constituents states being post-colonial nations and its recognition of the ICJ ruling against South Africa, but it had also come under an arms embargo due to its actions in terms of its systematic discrimination against its black African population. This opposition to the Apartheid regime was also reflected in the views of its neighbours, the majority of whom offered funding, supporting, and even basing to groups, both peaceful and militant, trying to bring about majority rule in South Africa. As the Border War dragged on, more and more of South Africa's neighbours became independent and began supporting these movements. The fight in Namibia thus became about maintaining a buffer zone between South Africa and the states supporting these movements, which it saw as having the potential to destabilize its Apartheid government.
However, the war between South Africa and SWAPO was never that simple. SWAPO was largely based in Angola, and so the twists and turns of the conflicts in that country, first represented by the Angolan War for Independence against Portugal, and then after Portugal's withdrawal in 1975, the Angolan Civil War, had profound effects on the course of the Border War. Portugal's withdrawal took pressure off SWAPO bases, meaning that South Africa had to engage in cross border incursions to strike at their opponents. The most dramatic of these, Operation Savannah (1975-1976), contributed to the Cuban intervention in Angola on the side of the Movement for the Liberation of the People of Angola (MPLA), as South Africa targeted them due to their backing of SWAPO. With Portugal gone, South Africa picked its own proxy in the war, UNITA, and would be in and out of Angola until the end of the war in 1988.
strengthened as they were by the UN over time. South Africa's development of nuclear weapons as a bluff against further Cuban action is also seen as a key factor in pushing it out of the war.
The big question about this conflict however is how it went on as long as it did, without South Africa, which had a government legitimized through a democratic system (despite its deep flaws), or SWAPO, a relatively ragtag independence movement propped up by external backers, throwing in the towel. As noted above, both sides viewed this conflict as existential, one in terms of claiming dignity and sovereignty, the other in terms of maintaining their political system. This made it extremely difficult for either side to compromise. But beyond this, both sides excelled at cost insulation, allowing them to fight despite incurring considerable attrition. On SWAPO's side, its large number of friends and allies willing to back it, including the Soviet Union, meant that if one backer faltered, others were there to take their place. On the South African side, censorship of the press by the Ministry of Defense, resourceful recruiting practices (including attracting ex-SWAPO soldiers, Angolans and Namibians to fight for them), and carefully calculated political risks (such as planning strikes into Angola to maximize pain to SWAPO while minimizing the international outcry) were all key aspects of their operations.
Despite the existential nature of the conflict, and both sides cost insulation measures, ultimately South Africa was ground down by SWAPO's external support and the UN arms embargoes it faced that eroded its technological superiority. The overwhelming international support for SWAPO, and consequent opposition to South Africa, can thus be seen to have played, in many ways, a decisive role in motivating its complete withdrawal from Namibia by late 1989.