The two main Irish nationalist and pro-British unionist parties in Northern Ireland agreed on Friday to return to devolved government for the first time in three years.