Most of Ireland seceded from the United Kingdom after the Irish War of Independence and the subsequent Anglo-Irish Treaty (1919–1922), with the six counties that formed Northern Ireland remaining as an autonomous region of the UK