Marthinus Pretorius, a leader of the Voortrekkers, founded the city in 1855 and named it Pretoria after his father's name, Andries Pretorius. In the Battle of the Blood River, Andries Pretorius became a national hero of the Voortrekkers and succeeded in negotiating the Sand River Convention (1852). After this convection, Pretoria, previously known as Transvaal, gained independence from the British. On 1st May 1860, the city became the capital city of the South African Republic (ZAR), which marked the end of the Boers' settlement movements of the Great Trek.
The Republican forces encircled the city during the First Boer War between December 1880 and March 1881. To end the war, a peace treaty was signed at the Pretoria convection on 3rd August 1881. The Second Boer War from 1899 to 1902 marked the end of the Transvaal Republic in Pretoria and displayed the intervention of the British in South Africa. As a result of the imprisonment of Winston Churchill at the Staats Model School in Pretoria along with his decision to escape Mozambique, the city was ceded to the British under the leadership of Frederick Roberts on 5th June 1900. Finally, the war ended after signing the Peace negotiations of Vereeniging on 31st May 1902.
During the Second Boer War, many forts were constructed to protect the city, but most of them got ruined. Some of the forts have been conserved as national monuments.
The unification of the Boer Republics of the ZAR, the Orange Free State, the Cape Colony and Natal Colony in 1910 represented the formation of the Union of South Africa. After the formation of the Union of South Africa, Pretoria gained the title of the administrative capital of South Africa, and Cape Town was the legislative capital. Pretoria was the capital of the province of Transvaal, replacing Potchefstroom between 1860 and 1994. Pretoria attained the official city position on 14th October 1931. The city remained the administrative capital of South Africa until it became a republic in 1961.
The Metropolitan Municipality of Pretoria and its surrounding towns were named Tshwane after forming new municipal structures across South Africa in 2000. The city's sinister image as 'the capital of Apartheid South Africa' was changed by selecting Nelson Mandela as the country's first non-apartheid president.
The provision to change the name of the city to match the name of the Tshwane municipality by the African National Congress at the beginning of 2005 met with rigid opposition. It deprived the city of its history as founded by Pretorius. Much of the opposition was from Afrikaner civil rights groups and political parties.