The city was founded by the Voortrekkers, following the defeat of Dingane at the Battle of Blood River, and was the capital of the short-lived Boer republic, Natalia. Britain took over Pietermaritzburg in 1843 and it became the seat of the Natal Colony's administration with the first lieutenant-governor, Martin West, making it his home. Fort Napier, named after the governor of the Cape Colony, Sir George Thomas Napier, was built to house a garrison. In 1893, Natal received responsibility for their own government and an assembly building was built along with the city hall. In 1910, when the Union of South Africa was formed, Natal became a province of the Union, and Pietermaritzburg remained the capital.
There exist two interpretations about the origin of the city's name. One is that it was named after Piet Retief and Gert (Gerrit) Maritz, two Voortrekker leaders. The other is that it was originally named after Piet Retief alone, since his full name was Pieter Maurits Retief. In this interpretation the original name was "Pieter Maurits Burg", later transliterated to the current name (Jenkins, 1971:11).
Retief in fact never reached Pietermaritzburg and was killed by Dingane, successor to Shaka, king of the Zulus. Maritz died of illness on 23 September 1838 near the present-day town of Estcourt, some hundreds of kilometres northwest of Pietermaritzburg. This was after the battle with the Zulus at Bloukranz, and Maritz did not ever reach the Pietermaritzburg area. In 1938, however, the city announced officially that the second element Maritz should also honour Gert Maritz.
At the time of the rise of the Zulu Empire, the site that was to become Pietermaritzburg was called Umgungundlovu. This is popularly translated from the Zulu as "Place of the Elephant", although it could also be translated to mean "The elephant wins". Umgungundlovu is thus thought to be the site of some Zulu king's victory since "Elephant" (Indlovu) is a name traditionally taken by the Zulu monarch. Legend has it that Shaka had his warriors hunt elephant there to sell the ivory to English traders at Durban (then called Port Natal). Today, the town is still called by its Voortrekker name, although the municipality of which it is part bears the Zulu name.