Algeria forward Riyad Mahrez's stunning free kick in stoppage time gave Algeria a 2-1 win over Nigeria in a tense Africa Cup of Nations semifinal played in a volatile atmosphere on Sunday.
It was a goal from the moment it left Mahrez's left foot as he stepped up and bent his shot into the far corner to leave goalkeeper Daniel Akpeyi helpless and send Algeria to their first final since 1990 -- the only time they won the tournament.
Algeria, who face Senegal in Friday's final, dominated the first half and should have had more than a 1-0 lead to show for it, courtesy of a William Troost Ekong own goal.
Nigeria equalised out of the blue midway through the second half with a penalty for handball converted by Odion Ighalo, his fourth goal of the tournament, after a lengthy VAR review.
There were ugly scenes in the crowd as bottles were thrown after the equaliser.
"It was a very, very tough game against a strong team," said Mahrez, who plays for English champions Manchester City.
"We were 1-0 up, good in the game and this decision of the VAR, of the penalty... they scored and we have this free kick and we scored, so we are very, very happy because to be in the final of AFCON is unbelievable."
Nigerian worries about their shaky defence were fully justified.
In Algeria's first serious attack, Akpeyi dived to stop a cross, missed and the ball bounced into striker Baghdad Bounedjah's hip at the far post but rebounded wide.
He then made a hash of punching clear a Mahrez cross and Ismail Bennacer's goal-bound shot was blocked by a defender.
Nigeria had further narrow escapes and, although they had a chance when Ighalo shot just wide from the edge of the area, it was only a respite and they went behind in the 40th minute.
Mahrez got free on the right and crossed into the middle where the ball hit Troost Ekong and flew into the net.
Nigeria saw more of the ball after half-time -- possibly because Algeria sat back -- but never really threatened until they were handed a lifeline by VAR.
Oghenekaro Etebo's shot appeared to hit Aissa Mandi's hand but the referee waved play on until, at the next break in play, he consulted the video officials and pointed to the spot.
Nearly four minutes after the incident, Igahlo sent goalkeeper Rais Mbolhi the wrong way in the 72nd.
The game seemed headed for extra time until a late flurry by Algeria saw Bennacer rattle the bar with a long-range drive and the outcome seemd almost inevitable when they won a free kick on the edge of the area and Mahrez stepped up to strike the winner.