After the Battle of Blood River in 1836 where the Voortrekkers broke the back of the Zulu army, and the death of Dingaan, the area south of the Tugela River became the Boer Republic of Natalia, and the area north of the river was Zululand.
The Boer Republic was only four years old when the British moved in, and then the area south of the Tugela became Natal. Because this is just a broad overview (things were a bit more complicated), suffice to say that the Voortrekkers then moved again and established the Boer Republics of Transvaal (with Pretoria as capital), and the Orange Free State (with Bloemfontein as capital). These republics were recognised as being independent by the British.
As part of the British resolve to bind the different territories into a federal scheme, in 1877 Sir Theophilus Shepstone annexed Pretoria. The Boers didn't have the means to resist, but Paul Kruger and two other leaders then started organising resistance with the idea to later take on the British.
In the meantime, in 1879, also under the guise of creating a federation of states in South Africa, the British forced the Zulus to accept British rule north of the Tugela (Anglo-Zulu War) and Zululand became part of Natal.
Shortly afterwards rising tensions between British settlers ("Uitlanders") and the Transvaal authorities led to the outbreak of the First Freedom War in 1880. The Boer resistance was now in place, and after a humiliating defeat at Majuba in 1881, Britain was forced to restore the right of self-government to the Transvaal.