Equatorial Guinea received a soft penalty in the dying seconds of normal time, enabling Javier Balboa to net a superb winner to seal a historic semi-final place for the African Nations Cup hosts in a 2-1 extra-time victory over Tunisia in Bata on Saturday.
The north Africans appeared to be on their way to the last four when Ahmed Akaichi put them ahead with 20 minutes to go.
But with just seconds remaining of normal time, Mauritius referee Rajindraparsad Seechurn handed the home side a dubious penalty that was converted by Balboa, who later grabbed the winner with a magnificent free kick.
It left Tunisia seething, and there were ugly scenes as tempers flared and Seechurn battled at times to contain the emotions.
The manner of the win will be debated long and hard. Certainly Equatorial Guinea benefitted from a soft penalty, but by that time the Tunisians could be accused of time-wasting and feigning injury as they tried to wind down the clock.
Equatorial Guinea will now play the winner of Sunday's quarter-final between Guinea and Ghana, with the ensuing semi-final fixture to be played on Thursday in Malabo.
Tunisia were almost gifted an opener when home goalkeeper Felipe Ovono dropped a ball into the box, but re-gathered just in time with Wahbi Khazri about to pounce.
Equatorial Guinea's best chance of the opening half also came from some uncertain goalkeeping, when Aymen Mathlouthi spilled the ball, but Balboa's goal-bound shot was blocked by Syam Ben Youssef.
Ovono made a superb save to deny Akaichi after the forward was teed-up by Yassine Chikhaoui as Tunisia made a fast start to the second half, but chances continued to be few and far between.
Akaichi finally broke the deadlock 20 minutes from the end when he profitted from a good cross by Hamza Mathlouthi to fire into the Equatorial Guinea net.
The home side had a great chance to equalise in the closing stages when Iban Edu found Emilio Nsue, but the star man saw his shot saved by Tunisian keeper Mathlouthi.
Then came what could yet be the pivotal moment in the competition.
Edu tumbled to the ground in the penalty box after what appeared to be minimal contact from Tunisian defender Hamza Matlhouthi and Seechurn pointed to the spot.
It took a while for the referee to calm the Tunisian protests, but when he did, Balboa stepped up and coolly slotted home the spot kick.
It was clear that Tunisia were rattled and they battled to reorganise themselves for the extra time period.
Again it was Balboa who provided the decisive moment as he curled home a 30-yard free kick that proved a worthy winner of any match, to send the home fans into complete rapture.
Equatorial Guinea are into the last four of the continental championship for the first time in their history, bettering the quarter-final finish they managed when they co-hosted the finals with Gabon in 2012.
This report has been re-edited since first published.