Nigeria snuck into the Africa Cup of Nations semifinals when William Troost Ekong scored with one minute remaining to give them a 2-1 win over a gallant South Africa as the tournament served up more drama on Wednesday.
Troost Ekong turned the ball in with his knee from a corner just as Nigeria seemed to be in danger of throwing away a game they dominated for more than an hour.
Samuel Chukwueze, recalled to the side after missing the previous round, put the Super Eagles in front when he scored at the second attempt in the 27th minute.
Nigeria stayed in control, missed chances and paid the price when Bongani Zungu headed an equaliser in the 71st minute with South Africa's first shot on target.
The goal was initially ruled offside but then awarded after a VAR check -- the first major intervention by technology since it was introduced for the quarterfinals.
"We had a plan, it was working, we scored, we failed to score a second goal," said Nigeria coach Gernot Rohr. "What I like in my team is that they never give up, they are never down, and they came back in the last minute, so this can take us very far."
Alex Iwobi burst down the left and pulled the ball back into the area to Chukwueze whose first effort was blocked by a defender but scored after it rebounded back to him.
Chukwueze, overlooked for the 3-2 last 16 win over Cameroon, was a constant menace down the right and created another chance after skipping past his marker but Dean Furman made a timely interception to deny him.
Nigeria looked too strong all-round for their rivals and nearly extended their lead early in the second half with a 25-metre free kick from Oghenekaro Etebo but Ronwen Williams turned it on the bar.
South Africa, who sensationally knocked out hosts Egypt in the previous round, struggled to get a look-in but the Super Eagles repeatedly failed to turn the mazy runs of Ahmed Musa and Chukwueze into goals.
Then, from out of the blue, South Africa equalised as Percy Tau lofted a free kick into the area, it was flicked on and superbly headed in by Zungu. It was initially disallowed but then given by a VAR check that took nearly three minutes.
Extra-time was looming until Nigeria won a corner on the left, Williams missed the ball and Troost Ekong prodded it home.
"It's difficult when you've lost the game in the dying minutes, it's difficult to find positives," said South Africa coach Stuart Baxter. "I'm sure in one week's time. I will find positives but now it's very difficult."