While hosts South Africa and debutants Cape Verde rejoiced, Morocco and Angola were left shattered because at various stages of the evening they seemed to be on the brink of a place in the quarter-finals.
The occasion certainly got to the coaches too. Cape Verde's Lucio Antunes burst into song during his post-match news conference while Morocco's Rachid Taoussi burst into tears.
The two topsy-turvy games produced their own version of footballing musical chairs.
South Africa's 2-2 draw with Morocco at the Moses Mabhida Stadium in Durban meant they topped the group with five points from three games, followed by Cape Verde in second place on the same total after a stunning 2-1 comeback win against Angola at the Nelson Mandela Bay Stadium in Port Elizabeth.
Morocco went home unbeaten after three successive draws while Angola, who faced the prospect of being eliminated even if they had beaten Cape Verde and South Africa had lost, finished bottom with one point.
The night began with the host nation top on four points followed by Cape Verde and Morocco on two and Angola with one.
That changed when Morocco took the lead against South Africa in the 10th minute through Issam El Adoua and Angola went ahead against Cape Verde after 33.
At that stage Morocco headed the group with South Africa in second place, Angola third and Cape Verde bottom. By the end of the night all four teams had changed positions several times over.
While events were unfolding in Durban, the drama was beginning in Port Elizabeth as Angola went ahead when Nando diverted a flick from Amaro into his own goal.
Despite the fact Angola were winning and South Africa were losing at that stage, if the results had stayed the same Angola would have been out and South Africa in.
Morocco, who had allowed South Africa to equalise through May Mahlangu after 71 minutes, went back in front and top of the group again when they forged 2-1 ahead with eight minutes to go.
Over in Port Elizabeth, Cape Verde equalised against Angola though Gege but that goal did not materially change much - it just meant that Cape Verde might finish on three points and Angola on two.
But what happened next changed everything as South Africa equalised against Morocco with four minutes to play.
"We knew what was going on in the other match, that's why I told the players to attack till the end," Antunes said.
Attack they did and Angola goalkeeper Lama made a dreadful attempt at stopping a speculative cross in the dying minutes, leaving substitute Heldon to stab the ball home in almost comic slow-motion.
With that the entire Cape Verde bench leaped high into the air and on to the pitch to engulf Heldon and anyone else in their path to celebrate one of the greatest international fairytales.
Massive underdogs Cape Verde, spread over 10 islands off the coast of west Africa, have a population of just 500,000.
"It is a small, quiet country but there will be singing and dancing there tonight that's for certain - with the coach joining in as you can see," said defender Nando.
- Sports & Recreation
- South Africa
- Cape Verde