The second Boer war lasted from 1899 to 1902. It was preceded by an attempt to oust the President of the Transvaal, Stephanus Kruger. At that time the Transvaal was independent of British rule (the Boers had gained control of it in the First Boer War.) Kruger had refused to give voting and other rights to British and other non-Boer residents (known as Uitlanders) and this was what prompted the attempt to get rid of him. The attack was known as the Jameson Raid, and was supported by Cecil Rhodes, who was then Prime Minister of the Cape Colony.
However, Kruger was not unseated and still refused to make concessions. There was an attempt at negotiation, but this failed. The Boers then began to invade British territory, including Mafeking and KImberley.
The British campaign was led by Lord Kitchener. In 1902 the Boers surrendered in the Peace of Vereenigung.