Gerald Phiri was also on target for The Flames as they set up a knockout fixture against Zambia on Sunday, though they still have to play their final Group B fixture.
The 0-0 draw between Seychelles and Mozambique earlier on Tuesday helped to ensure Malawi’s passage as they now head the table with six points.
Second-placed Namibia have three, but even if they win their final clash against Seychelles and Malawi lose, The Flames will still advance via a better head-to-head record over the Brave Warriors.
It means Malawi reach the quarterfinals for the first time since they won the Plate competition in 2015.
Mhango was denied by a last-ditch tackle from Namibia defender Charles Hambira when he seemed destined to score early on, with Malawi making the brighter start of the two sides.
But it was Namibia who grabbed the lead, Hambira ghosting in at the near post from a corner to head the ball into the back of the net.
That seemed to stun Malawi and the Brave Warriors might have been 2-0 up when Joslin Kamatuka found himself in acres of space on the edge of the box, but he delayed his shot too long and allowed the Malawian defence to scramble back and close him down.
Malawi attempted to find a way back into the game, but the Namibian defence held firm and created very little in the way of space in which they could play.
It took a moment of brilliance from Mhango to bring The Flames level as he powerfully hooked the ball into the back of the net from a tight angle, leaving Namibia goalkeeper Loydt Kazapua with no chance.
Malawi seized the initiative shortly after the break when they won a penalty after a foul on Richard Mbulu by Vitapi Ngaruka, referee Antonio Dungula from Angola pointing to the spot after consulting with his assistants.
It was the correct call and Phiri Junior expertly slotted the spot-kick in the corner of the net.
Seychelles held Mozambique to a goalless draw in the first Group B game on Tuesday.
It was a match of few chances, but Mozambique saw much more of the ball and dominated the game in terms of territory as well.
Seychelles keeper Ian Ah-Kong was by far the busier of the two glovemen but The Mambas could not force a winner.
The action continues on Wednesday when Comoros take on Mauritius in the deciding fixture in Group A at the same venue.
Eswatini lead the pool with two points, but have completed their matches, creating a winner-takes-all scenario between the two island nations.
The various scenarios are complex if the game ends in a draw, with the COSAFA Cup using the head-to-head system to separate teams, or failing that goal-difference and goals scored.
A 0-0 or 1-1 draw would leave all teams on two points, but see Eswatini advance based on their number of goals scored (4) in the pool stages.
If the match finishes 2-2 then all three teams will have two points, an even goal-difference and the same number of goals scored (4).
The teams would then be separated by Fair Play, based on the number of yellow and red cards they have received. Going into the fixture, the teams have as follows:
Eswatini: Two yellows
Comoros: One yellow
Mauritius: Two yellows
If the match ends 3-3 or as a higher score draw, then Eswatini will be eliminated. The pool will be decided by the Fair Play points between Comoros and Mauritius. If the teams cannot be separated by the Fair Play points then the pool will be decided by the drawing of lots.
Seychelles 0 Mozambique 0
Namibia 1 (Hambira 16’) Malawi 2 (Mhango 34’, Phiri Jnr 48’pen)
Comoros vs Mauritius (KO 17h30; 15h30 GMT) – King Zwelithini Stadium
Group A P W D L GF GA Pts
Eswatini 2 0 2 0 4 4 2
Comoros 1 0 1 0 2 2 1
Mauritius 1 0 1 0 2 2 1
Group B P W D L GF GA Pts
Malawi (Q) 2 2 0 0 5 1 6
Namibia 2 1 0 1 3 3 3
Mozambique 2 0 1 1 1 2 1
Seychelles 2 0 1 1 0 3 1
Matches Played: 6
Goals scored: 17
Biggest victory: Malawi 3 Seychelles 0 (Group B, May 26)
Most goals in a game: 4 – Eswatini 2 Mauritius 2 (Group A, May 25); Eswatini 2 Comoros 2 (Group A, May 27)
2 goals – Felix Badenhorst (Eswatini), Gabadinho Mhango (Malawi), Ashley Nazira (Mauritius), Gerald Phiri Jnr (Malawi)
1 – Charles Hambira (Namibia),Youssouf Ibroihim (Comoros), Absalom Iimbondi (Namibia), Joslin Kamatuka (Namibia), Siboniso Mamba (Eswatini), Richard Mbulu (Malawi), Sabelo Ndzinisa (Eswatini), Boina Bacar Raidou (Comoros), Witi (Mozambique)