After a strong team performance in their win over Angola, the expectations of Bafana Bafana' supporters were high ahead of their last Group A match. They, however, had to endure an ju-and-down roller-coaster ride of a contest before a late goal secured South Africa top spot in Group A and a place in the quaterfinals.
The South Africa team's nerves were on show early in the contest, but driven on by the home support, they improved as the match progressed and they were eventually rewarded with a hard-earned, entertaining 2-2 draw.
At the back, goalkeeper Itumeleng Khune did as much as anyone to keep the hosts in the tournament with a string of excellent saves, while central defender Siyabonga Sangweni turned goal scorer again.
In the midfield, Dean Furman toiled manfully, while May Mahlangu showed some classy touches, which included a stunning goal.
Thuso Phala ran hard at the Moroccan defenders throughout the match, while Bernard Parker got through a ton of work. In the end, though, it was an all-round team performance that saw South Africa through to the next stage of the tournament.
For a while, though, it appeared their dream of Afcon success would end at the final group stage hurdle.
On the back foot
The North Africans managed the first shot on goal in the third minute from a corner and a minute later Itumeleng Khune had to react quickly to prevent Youssef El-Arabi from getting onto the end of a ball into the South African area. Khune parried the shot on the edge of the box and then took the ball comfortably when it spun back into the area.
Khumalo then needed to make a difficult clearance from a free kick swung into the six-yard box after Thuso Phala had committed a foul out on the Moroccans' left flank.
The Lions of the Atlas had certainly settled sooner than South Africa and were taking the game to the tournament hosts.
Tokelo Rantie turned Mehdi Benatia easily in the eighth minute and powered his way into the area. Teh defender tugged on his shirt, but didn't make enough of an impact to award for a penalty to be awarded against Morocco as Rantie went down in the box.
Shortly after that, in the 10th minute, the men in red went a goal up from a corner. Khune missed with an attempt at a punch and central defender Issam El Adoua rose high above Siyabonga Sangweni to header home from very close range.
Phala then went down in the Moroccan box two minutes later, but there was minimal contact by the defender and he was lucky not to be shown a yellow card after a very delayed reaction to the challenge.
Rain was falling and plenty of niggling tackles made for a stop, start affair as the referee had to blow for a free kick time after time. Slowly, though, the match found its rhythm
Chahir Belghazouani almost made it 2-0 to Morocco when Khune spilt his shot, but the ball passed around the outside of Bafana's left-hand post. El Adoua managed a powerful header, but was wide of the mark. Ominously for the home supporters, South Africa were clearly struggling at set piece time.
The home side fought back and Kamel Chafni brought May Mahlangu down as the Sweden-based midfielder made a run deep into the North Africans' territory. From their first set piece opportunity, South Africa made a right mess of it and Morocco counter-attacked.
The Lions of the Atlas looked assured on the ball, having more time to find their own men than they were affording Bafana Bafana when the men in yellow had it.
A decent attack opened up a shot for Bernard Parker, but it was was deflected and slowed down, allowing the goalkeeper to gather the ball before it crossed the line.
Parker then got away South Africa's first decent effort from the left, but his aim was slightly off and the ball passed harmlessly across the face of goal.
After nine early fouls between the teams, Belghazouani became the first player booked in the 28th minute.
Despite being down by a goal after the first half-hour, South Africa were still on course for the quarterfinals as the second place finishers in the group, with the game between Cape Verde and Angola level at nil-nil in Port Elizabeth.
The tension in the game was clear to see when Anele Ngongcga was yellow carded for a bad tackle and players from both teams converged on the referee. At about the same time, news of a goal to Angola came through. Still, the advantage belonged to the tournament hosts, who owned the tie-breaker, having defeated the Angolans.
A speedy counter-attack from Rantie after Bafana had defended a corner almost opened up the Moroccan defence, but they ultimately conceded a corner, which Bafana failed to make good use of.
Chafni then beat Dean Furman in the South African box, but Parker darted in to nip the ball away from his feet.
With half-time approaching, Bafana Bafana began to push Morocco back and managed to work their way deep into the North Africans' territory without finding a testing finish for goalkeeper Nadir Lamyaghri as the Moroccan central defence stood strong, led by Benatia. South Africa, though, looked more composed on the ball than they had earlier been.
A minute before the break, however, Chafni was put through on goal, forcing Khune to come a good 15 metres out of his box to challenge. Chafni tried to nutmeg the South African net-minder, but Khune dropped onto his knees and onto the ball and then cleared for the sideline.
Morocco led at the break. They had dominated the early going, but Bafana Bafana looked better as the half progressed. A tension-filled second half was on the cards and so it played out. Before play restarted, South African captain Bongani Khumalo pulled his men together in a circle on the pitch, urging them to find a reply to the Moroccans' goal.
Barada took on Khune from range early on. His low, skimming shot was on target, but Khune saved comfortably to his left.
Phala managed a teasing cross along the ground, but Moroccan goalkeeper Lamyaghri met it at the left hand post as no one from South Africa made a run.
Five minutes into the half, coach Gordon Igesund opted to replace Katlego Mphela, who had been very quiet, with Thulani Serero, taking off a target man for a more skilful player.
A free kick in the 52nd minute, from just outside the Moroccan box was taken by Phala, forcing a diving one-handed save from the goalkeeper as the ball headed for Lamyaghri's top right hand corner.
Abdelilah Hafidi, who had come on only minutes earlier was shown a yellow card after fouling Serero and then kicking the ball way. South Africa's push for an equaliser continued, much in the same form as they had pressed before the half-time whistle.
Hearts in mouths
The hearts of the home fans were in their mouths, though, when Sangweni made a mistake at the back and Al Arabi raced through to challenge Khune. The goalkeeper rushed off his line and deflected the striker's attempt at a chip with a fine effort to keep South Africa in the game.
Bafana responded with a shot from Serero, but Lamyaghri got his body behind the ball and dropped down to field it.
With just over an hour played, the group standings remained unchanged. If the scores in the two games remained the same, Morocco would top the group with South Africa in second, Angola in third and Cape Verde in fourth.
Phala delivered a good corner from the left, but Sangweni, at the far post, was unable to make good contact with the ball and a goal kick resulted.
Chafni brought down Serero and was booked. Furious, he remonstrated with the Gambian referee Bakary Papa Gassama. Replays suggested he might have had a case. Phala's free kick curled just over the South African forwards, but it turned into a difficult save for Lamyaghri, who was forced to turn it around his post.
The Moroccan goalkeeper then required treatment on an elbow, which underlined Morocco's tactic of slowing the contest down as 25 minutes to play showed on the clock. Already there had been a few other time wasting incidents and South African skipper Bongani Khumalo drew the ref's attention to it. On the sideline, Bafana coach Gordon Igesund exhorted his men to get forward and take the game to the Lions of the Atlas.
South African goal
In the 71st minute, his team responded. Picking up the ball on the left, just outside the Moroccan box after playing a one-two with Rantie, May Mahlangu curled a beautifully judged shot beyond Lamyaghri into the goalie's top left hand corner. Mahlangu had little time to react before he was swamped by a sea of yellow and green clad players. The crowd celebrated and the noise level lifted.
The goal meant Bafana Bafana were now top of the group again, with Angola up to second and set to also reach the quarterfinals. Morocco were down to third and Cape Verde remained fourth.
Parker picked up a yellow card in the 74th minute, just before Phala floated in another free kick, which forced a diving punch out of the goalkeeper. A short while later, Parker made way for his Kaizer Chiefs' team-mate Reneilwe Letsholonyane.
With 15 minutes remaining, Morocco were forced to adjust their style of play, needing to score another goal to advance. South Africa, though, defended resolutely and the clock ticked down to 10 minutes to play.
News then came through that Cape Verde had leveled in Port Elizabeth. Moments later, South Africa conceded a goal. El Arabi created space on the left and when the ball was cut back deep, Hafidi chested it down and beat Khune to his left to make it Morocco 2, South Africa 1. The crowd went quiet.
Morocco were back on top of the standings, South Africa down to second, Cape Verde up to third and Angola down to fourth.
A short while later Chafni brought Serero down on the edge of the Moroccan box with a tackle that could have earned him a second yellow card. The referee, however, did not reach for his pocket. Phala's free kick flew disappointingly high over goal.
With only four minutes of regulation time remaining, the crowd came back to life as central defender Sangweni netted for a second match in succession. Showing the composure of a good striker, he controlled the ball and then curled a lovely, low shot wide into the goalkeeper's bottom left hand corner. The South African players rushed to embrace him. Now South Africa topped the group.
Four minutes of stoppage time were added on as the contest hit its 90th minute. Out in the middle of the pitch, Mahlangu lay in pain on the ground. He looked to have pulled a muscle. Kagisho Dikgacoi ran on in his place.
At the Nelson Mandela Bay Stadium, Cape Verde took the lead from Angola. They were up to second. What it meant was a goal by Morocco would knock South Africa out of the tournament.
Khune then went down, suffering from cramp, drawing out the tension as the Bafana Bafana fans waited anxiously for the final whistle. Confirmation was received that Cape Verde had won. They were guaranteed a quarterfinals' place in their first Afcon finals tournament.
Finally the whistle to end the match arrived. Igesund bounced onto the pitch, fists clenched, punching the air. Bafana Bafana were through.
South African fans celebrated while Morocco's players sat disconsolately on the pitch, their dream over. They had brought a lot to the game, but had come away with nothing in the end.
The Bafana Bafana players surrounded Igesund, making a circle, before breaking up to turn to the fans and signal their thanks for their support.