Three-time winners Angola crashed out of the Cosafa Cup on Thursday after failing to score for a second successive match and being pipped to top place in Group A by guest team Tanzania.
Angola and Tanzania started the last round of group games equal on points, but with Tanzania (+2) having a better goal-difference.
But a goalless draw for Angola (+1) against Malawi at the Royal Bafokeng Sports Palace, combined with a 1-1 draw for Tanzania against Mauritius at the same time at the Moruleng Stadium in South Africa's North West Province, meant the Taifa Stars went through by the slimmest of margins.
Tanzania will now face defending champions and hosts South Africa in the quarterfinal on Sunday.
They had to come from a goal down to draw with gutsy Mauritius, who finished above Malawi on goal-difference in third place.
Kevin Perticots came on at halftime to net a 67th-minute goal for Mauritius - their first of the tournament - but the lead lasted less than 60 seconds before Saimon Msuva equalised to put Tanzania back in contention, with their task in the last 15 minutes made easier when Mauritius had full-back Damien Balisson sent off.
Angola's best chance of grabbing the goal they needed to advance came midway through the second half from diminutive striker Va, making his first appearance of this year's Cosafa Castle Cup. He jinxed his way through two tackles but could not get any decent power into his final effort.
"We are sad to leave the competition, not happy at all because our objective was to past the first round. But we had a tough opponent and we knew it wouldn't be easy. We were able to take ball away from Malawi in the second half but then we were not lucky in front of goal," said Angola coach Beto Bianchi.
Profligacy in front of goal effectively cost Palancas Negras. Manguxi scored for them in the opening five minutes of their first match against Mauritius, but for the remaining 265 minutes they played at the annual southern African championship they failed to find the net and pay the resultant price.