The War of Independence ended with the Anglo-Irish Treaty, signed on 6 December 1921 and narrowly approved by Dáil Éireann on 7 January 1922. A Provisional Government was set up under the terms of the treaty, but the Irish Republic nominally remained in existence until 6 December 1922, when 26 of the island's 32 counties became a self-governing British dominion called the Irish Free State. The island had been partitioned by the Government of Ireland Act 1920, and the six counties of Northern Ireland, which had been partitioned so as to create and ensure a unionist majority, exercised their right under the treaty to opt out of the Free State, and remain in the United Kingdom.