They finished level on five points after three matches with Angola but take top place by virtue of a better goal difference.
Tanzania ended with a goal difference of plus two to plus one for three-time winners Angola, whose final game with Malawi ended goalless at the Royal Bafokeng Sports Palace in Phokeng.
The two matches were played simultaneously.
Tanzania started with star striker Tomas Ulimwengu for the first time in the tournament. He is based in Sweden but has been struggling with an ankle injury.
He had three good chances in the first half but Mauritius held them goalless at halftime, even though Tanzania’s Yahya Ramadhani struck the post.
The Islanders were the first to net through Kevin Perticots, who had come on after halftime. A counter attack allowed a breakaway and he chipped the goalkeeper for Mauritius’ first goal of the tournament.
But the lead lasted less than 60 seconds as Saimon Msuva equalised to put Tanzania back in contention.
Mauritius then had fullback Damien Balisson sent off, leaving them one man short as Tanzania pushed for the elusive winner.
Malawi, who still had a slim mathematical chance of progressing, made a bright start to their match with a mazy run from Dalisto Sailesi in the third minute before having his effort saved by Neblu in the Angolan goal.
Angola’s best effort came from diminutive striker Va, making his first appearance of this year’s Cosafa Castle Cup. He jinked his way through two tackles but could not get any decent power into his final effort.
Angola pressed furiously in the closing minutes but could not find that elusive goal, leaving the tournament having scored just once.
Tanzania will now meet defending champions South Africa in the last eight at the Royal Bafokeng Sports Palace on Sunday.
On Friday, Group B will be concluded when Madagascar take on Mozambique at the Moruleng Stadium and Zimbabwe clash with the Seychelles at the Royal Bafokeng Sports Palace.
The two matches will bring the curtain down on the first round.
THURSDAY’S RESULTS
Group B
Malawi 0 Angola 0
Tanzania 1 (Msuva 69’) Mauritius 1 (Perticots 68’)
FRIDAY’S FIXTURES
Group A
Mozambique v Madagascar KO: 5pm CAT (SA, GMT+2) – Moruleng Stadium
Zimbabwe v Seychelles KO: 5pm CAT (SA, GMT+2) – Royal Bafokeng Stadium