Slavery was outlawed when the British entered into a constitutional arrangement with New Zealand in 1840 via the Treaty of Waitangi, although it did not end completely until government was effectively extended over the whole of the country with the defeat of the King movement in the Wars of the mid-1860s.