Wales will play Northern Ireland in the last 16 of Euro 2016, while England take on Iceland and the Republic of Ireland face France.
The Republic were minutes from going out but came third in Group E with a late 1-0 win over Italy and go through.
Wales, who topped Group B, play Michael O'Neill's Northern Ireland in Paris on Saturday (17:00 BST) live on BBC One.
England, who were runners-up behind Wales, play surprise Group F runners-up Iceland in Nice on Monday (20:00 BST).
Martin O'Neill's Republic of Ireland side, who, like Northern Ireland, qualified as one of the four best third-placed teams, take on hosts France in Lyon on Sunday at 14:00 BST.
Northern Ireland and Wales had never reached the European Championship finals before this year's competition, the first to feature 24 teams, while it is the first time the Republic have made the knockout stages at the Euros.
The last time the Republic of Ireland played France was in 2009, when Thierry Henry handled the ball in the build-up to the deciding goal in a World Cup qualification play-off.
With a population of just 330,000, England's opponents Iceland are the smallest nation ever to qualify for the tournament.
The Republic of Ireland were heading out before a late Robbie Brady header gave them a 1-0 win over Italy and sent them through as another one of the best third-placed teams.
Winger James McClean said the sight of "grown men crying and complete love for our country" was "quite remarkable".
He added: "We knew it would be win or bust. We left nothing on the field. The best night of my life, hands down."
Goalscorer Brady said he was "absolutely flabbergasted" by the result and described it as an "out of body experience".
That dramatic climax echoed scenes earlier on Wednesday as Iceland sealed second place in Group F by scoring a last-minute goal to beat Austria 2-1.
Had Iceland not won, England would have faced Portugal in the last 16.
The Portuguese, who now play Group D winners Croatia, knocked England out of the European Championship in 2004 and the World Cup in 2006, with both games decided by a penalty shootout.
The Full Draw
(All times BST)
Switzerland v Poland - Saturday 14:00, BBC
Wales v Northern Ireland - Saturday, 17:00, BBC
Croatia v Portugal - Saturday, 20:00, ITV
France v Republic of Ireland - Sunday, 14:00, ITV
Germany v Slovakia - Sunday, 17:00, ITV
Hungary v Belgium - Sunday, 20:00, BBC
Italy v Spain - Monday, 17:00, BBC
England v Iceland - Monday, 20:00, ITV
Former Republic of Ireland international Kevin Kilbane on BBC Radio 5 live: "It does not get any better than this. We wanted this, we were desperate for this.
"It is amazing. I am so happy for Martin O'Neill, the staff and the supporters. They have done us all proud. This is incredible."
The draw means at least one of the home nations will make the quarter-finals.
Northern Ireland manager Michael O'Neill said his team will take on Wales with the benefit of having played at the Parc des Princes.
He added: "The results tonight put us in what is arguably the more favourable side of the draw, so we are pleased about that."
The stats you need to know
-Portugal forward Ronaldo became the first player to score at four Euros when he netted against Hungary.
-This year's final is already guaranteed to feature a nation that has never won a major tournament.
-England averaged 60.5% possession in the group - Iceland had 29.0%.
-Victory over Italy was the Republic of Ireland's first Euros win since beating England in their first ever game at the finals in 1988.
-Wales and Hungary scored more goals than any other team in the group stages, finding he next six times.
-69 goals have been scored so far, a rate of 1.92 per game, the lowest average for a Euros group phase since 1992 (1.75).
-27.5% of the goals came from the 80th minute onwards (19).
-This is the first time since 1996 that no team won all three group games.