Match ends, Nigeria 2, South Africa 1.
Africa Cup of Nations: Nigeria score in last minute to beat South Africa 2-1 for semi-final spot
William Troost-Ekong scored a dramatic late winner to send Nigeria into the Africa Cup of Nations semi-final at the expense of South Africa.
Samuel Chukwueze hit the opener as he controlled Alex Iwobi's cross, before scoring at the second attempt.
Bongani Zungu equalised with a header initially ruled out for offside before VAR replays showed a free-kick hit a Nigerian player on the way to him.
But Udinese's Troost-Ekong bundled home from close range late on to win it.
His finish was into an empty net after goalkeeper Ronwen Williams totally missed Moses Simon's corner.
Nigeria face Ivory Coast or Algeria in Sunday's second semi-final (20:00 BST).
The Super Eagles were deserved winners and led through Villarreal youngster Chukwueze's first goal for his country. They should have been ahead by more when Williams pushed Peter Etebo's free-kick onto the bar.
Zungu's goal was the first in the Africa Cup of Nations given by the VAR, which has just been introduced for the quarter-finals. It looked offside initially but Percy Tau's free-kick hit Nigeria's Odion Ighalo on the way on to Amiens midfielder Zungu's head.
The game looked set for extra time before Williams flapped at a cross to leave Troost-Ekong with a simple finish.
Senegal, who beat Benin 1-0 earlier on Wednesday, play either Madagascar or Tunisia in the other semi-final.
Everyone thought it was offside - analysis
BBC World Service's Nick Cavell at the Cairo International Stadium
Probably the correct result in the end.
All three goals were quite scrappy. The first one for Chukwueze took a deflection.
Then South Africa's equaliser thanks to the VAR decision, which was a bit of history here. Everyone in the stadium thought it was offside - that was what the linesman flagged for - but the replay proved VAR was useful, correct and worth doing because it proved the ball had come off Ighalo and not Thulani Hlatshwayo, and so it stood.
But South Africa didn't do enough to win this - they were caught between trying to pump it long and trying to pass it around a very solid Nigerian defence.
And it was Troost-Ekong who was at the heart of that defence and scored the winner. Nigeria had class through the side though - Iwobi had another outstanding game, as did Etebo and Chukwueze.
- 18IwobiSubstituted forBalogunat 90+3'minutes
- 7MusaBooked at 35minsSubstituted forSimonat 81'minutes
- 5MkhizeBooked at 75mins
- 14HlatshwayoBooked at 49mins
- 19TauBooked at 62mins
- 9MothibaBooked at 14minsSubstituted forVeldwijkat 86'minutes
- 23LorchSubstituted forZwaneat 58'minutes
- Rédouane Jiyed
- Shots on Target
Second Half ends, Nigeria 2, South Africa 1.
Substitution, Nigeria. Leon Balogun replaces Alex Iwobi.
Corner, Nigeria. Conceded by Ronwen Williams.
Attempt saved. Odion Ighalo (Nigeria) right footed shot from the right side of the box is saved in the bottom right corner. Assisted by Samuel Chukwueze.
Goal! Nigeria 2, South Africa 1. William Troost-Ekong (Nigeria) right footed shot from very close range to the bottom right corner. Assisted by Moses Simon with a cross following a corner.
Corner, Nigeria. Conceded by Bongani Zungu.
Attempt blocked. Kenneth Omeruo (Nigeria) header from the left side of the box is blocked. Assisted by Moses Simon with a cross.
Corner, Nigeria. Conceded by Thulani Hlatshwayo.
Foul by Lars Veldwijk (South Africa).
Wilfred Ndidi (Nigeria) wins a free kick in the defensive half.
Percy Tau (South Africa) wins a free kick on the right wing.
Foul by Jamilu Collins (Nigeria).
Buhle Mkhwanazi (South Africa) wins a free kick in the defensive half.
Foul by Odion Ighalo (Nigeria).
Substitution, South Africa. Lars Veldwijk replaces Lebo Mothiba.
Foul by Lebo Mothiba (South Africa).
Moses Simon (Nigeria) wins a free kick in the defensive half.
Attempt saved. Percy Tau (South Africa) left footed shot from the right side of the box is saved in the top right corner. Assisted by Lebo Mothiba.
Hand ball by Lebo Mothiba (South Africa).