In the 19th century, hostilities broke out between Tswana inhabitants of Botswana and Ndebele tribes who were making incursions into the territory from the north-east. Tensions also escalated with the Dutch Boer settlers from the Transvaal to the east. After appeals by the Batswana leaders Khama III, Bathoen and Sebele for assistance, the British Government put "Bechuanaland" under its protection on 31 March 1885. The northern territory remained under direct administration as the Bechuanaland Protectorate and is modern-day Botswana, while the southern territory became part of the Cape Colony and is now part of the northwest province of South Africa. The majority of Setswana-speaking people today live in South Africa.
When the Union of South Africa was formed in 1910 out of the main British colonies in the region, the Bechuanaland Protectorate, Basutoland (now Lesotho) and Swaziland (the "High Commission Territories") were not included, but provision was made for their later incorporation. However, their inhabitants began to be consulted by the UK, and although successive South African governments sought to have the territories transferred, the UK kept delaying; consequently, it never occurred. The election of the Nationalist government in 1948, which instituted apartheid, and South Africa's withdrawal from the Commonwealth in 1961, ended any prospect of incorporation of the territories into South Africa. An expansion of British central authority and the evolution of tribal government resulted in the 1920 establishment of two advisory councils to represent both Africans and Europeans. Proclamations in 1934 regulated tribal rule and powers. A European-African advisory council was formed in 1951, and the 1961 constitution established a consultative legislative council.
In June 1964, the UK accepted proposals for a democratic self-government in Botswana. The seat of government was moved in 1965 from Mafikeng in South Africa, to the newly established Gaborone, which sits near its border. The 1965 constitution led to the first general elections and to independence on 30 September 1966. Seretse Khama, a leader in the independence movement and the legitimate claimant to the Ngwato chiefship, was elected as the first President, going on to be re-elected twice.
The presidency passed to the sitting Vice-President, Quett Masire, who was elected in his own right in 1984 and re-elected in 1989 and 1994. Masire retired from office in 1998, and was succeeded by Festus Mogae, who was elected in his own right in 1999 and re-elected in 2004. The presidency passed in 2008 to Ian Khama (son of the first President), who had been serving as Mogae's Vice-President since resigning his position in 1998 as Commander of the Botswana Defence Force to take up this civilian role.
A long-running dispute over the northern border with Namibia's Caprivi Strip was the subject of a ruling by the International Court of Justice in December 1999, which ruled that Kasikili Island belongs to Botswana.