The Potters sacked Nathan Jones a week ago after he failed to point them back in the direction of the Premier League, and they have now turned to the highly regarded O’Neill.
The 50-year-old has impressed in charge of Northern Ireland, taking them to the finals of Euro 2016.
He has decided to return to club management, though, starting at Barnsley on Saturday, but will then return to complete his duties with Northern Ireland in the forthcoming European qualifiers against Holland and Germany.
While confirming the departure of O’Neill, the Irish Football Association also said he would return for any Euro 2020 play-off matches in March.
Speaking about O’Neill’s exit, Irish FA chief executive Patrick Nelson said: “We reluctantly agreed to allow Stoke to talk to Michael after they met the compensation requirements. Michael has now agreed terms with the Championship club.
“Naturally, we are extremely disappointed that Michael is leaving us, however we are delighted all parties have agreed Michael will be in charge of the Northern Ireland team for the games against Holland and Germany and potential Euro 2020 play-off matches in March.
“Everyone in the GAWA family is grateful for Michael’s inspirational contribution over the past eight years. After a difficult start to his managerial reign with Northern Ireland he honed an excellent squad and took us to the round of 16 at Euro 2016, our first major tournament in 30 years. And, of course, he also took us to a play-off for World Cup Russia 2018 and the team have performed extremely well during the Euro 2020 qualification campaign.
“He has instilled incredible belief among our players and inspired countless young people to play football and aspire to play for Northern Ireland. He has also given our wonderful fans plenty to cheer about in recent years.”
O’Neill, a well-travelled midfielder during his playing days, started out as a manager in 2006 at Brechin, before moving to Shamrock.
He made the step up to international management on the back of two Ireland Premier Division titles with Shamrock in 2010 and 2011 and turned down an offer from Scotland in January 2018.
Stoke, relegated from the Premier League in 2018, sacked Jones last week and sit rock bottom of the Sky Bet Championship with eight points from 15 games.