Amongst a hail of atrocious tackles and off-the-ball incidents, Tunisia took the lead when Ahmed Akaichi swept home midway through the second half.
But a controversial penalty decision in injury time handed Equatorial Guinea a lifeline.
Spain-born striker Javier Balboa, who was once on Real Madrid's books, scored and sent the game into extra time and towards an ecstatic, and violent, conclusion.
Tunisia's players could scarcely believe what was happening. Punches were thrown behind the referee's back as play acting ruined the game's fluency.
The referee again awarded a controversial free kick in the first half of extra time but there was nothing controversial about what happened next.
Balboa stepped up again and incredibly curled the ball into the top corner to give the hosts a shock 2-1 lead.
The game degenerated into a flurry of conflicts, fights and faked injuries.
The referee blew the final whistle a full 15 seconds before the end and had to be escorted down the tunnel by armed police as Tunisian players and officials chasing him down the tunnel, marring what ranks as the finest moment in the country's soccer history.
The hosts are ranked 118th in the world by FIFA and were not scheduled to even compete in the tournament.
Equatorial Guinea had initially been thrown out of qualification in the first round back in May 2014 after fielding an ineligible player. Several matches during their attempt to qualify for the 2014 World Cup were also awarded to the opposition for the same reason.
But the Ebola crisis that has engulfed west Africa led to fears in Morocco, the original host country, that fans might bring the disease with them. After a lengthy saga, they eventually pulled out at the last minute. Equatorial Guinea, who co-hosted in 2012, stepped in and were reinstated.
The build up to the tie had seen the hosts evoke the spirit of the Denmark national team of the early 1990s.
Denmark failed to qualify for the 1992 European Championships but after Yugoslavia were ejected due to the civil war raging in their country, the Danes were given a free pass into the tournament.
They went on to win it.
"We have the will to win and we like the challenge in front of us. We are hungry for victory," Equatorial Guinea's coach Esteban Becker said in a press conference earlier in the tournament.
"Denmark were instated in the 1992 European Championship at the last minute and they went on to win it. We want to do that too."
Yet that Denmark team, although in decline, was still considered to be one of Europe's most cultured teams. Equatorial Guinea were one of the lowest ranked teams in the Africa Cup of Nations. They will now play the winner of Ghana and Guinea, who play Sunday.
Congo v Congo
The Democratic Republic of Congo also made it to the semifinals after a dramatic 4-2 victory over Congo.
With the game tied 0-0 at half time there appeared to be little danger of a six-goal thriller. But the game burst into life in the second half.
Congo raced into a 2-0 lead before a stunning comeback saw the Democratic Republic of Congo score four times without reply. They will now play the winner of Ivory Coast and Algeria, who also play Sunday.