Maybe that was too short: what I meant was that the war of independance ended with a treaty:
"The Anglo-Irish Treaty (Irish: An Conradh Angla-Éireannach), officially called the Articles of Agreement for a Treaty Between Great Britain and Ireland, was a treaty between the Government of the United Kingdom of Great Britain and Ireland and representatives of the secessionist Irish Republic that concluded the Irish War of Independence. It established the Irish Free State as a self-governing dominion within the British Empire and also provided Northern Ireland, which had been created by the Government of Ireland Act 1920, an option to opt out of the Irish Free State, which it exercised." from Wikipedia.
The war of independence was about independence, and not everybody felt that being a dominion within the British Empire was independence from the British Empire.
The Northern Ireland problem was created with the Government of Ireland Act 1920:
The Act was intended to establish separate Home Rule institutions within two new subdivisions of Ireland: the six north-eastern counties were to form "Northern Ireland", while the larger part of the country was to form "Southern Ireland". Both areas of Ireland were to continue as a part of the United Kingdom, and provision was made for their future unification under common Home Rule institutions. Wikipedia.