Andre Ayew of Ghana celebrates scoring his teams second goal during their 2015 Africa Cup of Nations soccer match against South Africa. Photo: BARRY ALDWORTH

Johannesburg - South Africa were sent crashing out of the Africa Cup of Nations after relinquishing a one-goal lead for a third match in a row against Ghana in Mongomo on Tuesday night, losing 2-1.

Mandla Masango had sent Bafana Bafana into the lead after 17 minutes with a wonder-strike from the edge of the area in Equatorial Guinea, but John Boye's equaliser on 73 minutes was all it took to condemn the South Africans to bottom of group C.

But there was more misery to come for Shakes Mashaba and his outfit when Andre Ayew scored the winner seven minutes from the end, ending South Africa's campaign with a single point from three outings.

Masango was one of four changes by Mashaba, who named Brilliant Khuzwayo in goal - a third goalkeeper in as many matches - while Bongani Ndulula started ahead of Sibusiso Vilakazi, and Rivaldo Coetzee was back in the team ahead of Thulani Hlatshwayo, who was out with concussion.

A deflated South African team limped to full-time as Ghana bagged a vital win on a night when permutations dictated that all eyes were on the second game of the group, where Algeria ran out 2-0 winners over Senegal.

Senegal could have done South Africa a favour by beating Algeria in that game, but even if West Africans could have managed the feat, Bafana's defeat sealed Ghana's progression, Algeria topping the group with a superior goal-difference over the Black Stars.

With Algeria winning by two goals, South Africa would have progressed to the next stage had they held on to their 1-0scoreline, but it was not to be for a Bafana outfit that had gone six games unbeaten in the Cup of Nations qualification tournament.

As with the opening two fixtures against Algeria and Senegal, Bafana were the first to score but frailties at the back allowed Ghana to come storming back, as South Africa's back line were exposed and ultimately cost the country a place in the knockout rounds.

A nervy start had South Africa on the back foot from the first whistle, but when Masango netted a fantastic snap-shot volley with 17 minutes on the clock, hopes of an unlikely qualification out of a tough group looked a realistic prospect.

News had already filtered in that Algeria had stolen the lead in the other game in Malabo, which kicked off simultaneously, when Riyad Mahrez opened the scoring after 11 minutes.

That set South Africa up for a nervy finish where a second goal would have wrapped up the group, but once Ghana showed their class and took second place in the group when Senegal looked favourites to do so.

Bafana's performance in the second half lacked killer instinct and the team looked like one holding on for dear life, instead of searching for a second.

Boye needed little encouragement when he netted Ghana's first, which had looked on the cards for some time.

Not long after, Ayew put the result to bed with his header which Khuzwayo was no match for as a disappointing tournament came to an end for the 1996 champions.

Sapa