O'Neill will take charge of Saturday's visit to Barnsley, but will return to lead Northern Ireland's final two Euro 2020 qualifiers against Germany and the Netherlands later this month and potential playoff matches in March.
Northern Ireland could still qualify automatically as they trail both Germany and the Netherlands by three points in Group C with two games to play, but are likely to receive a second chance via a Nations League playoff even if they fail to produce a massive upset in their final two qualifiers.
O'Neill, 50, has impressed in eight years in charge of Northern Ireland, taking them to a first major tournament in 30 years at Euro 2016, where they reached the last 16.
"We reluctantly agreed to allow Stoke to talk to Michael after they met the compensation requirements," Northern Irish FA chief executive Patrick Nelson said in a statement.
"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."
Stoke, relegated from the Premier League in 2018, sacked Nathan Jones a week ago with the Potters rock bottom of the Championship with just eight points from their first 15 games.