Comoros, representing a tiny island nation off the south east coast of Africa, finished third and must wait until Thursday to know if they are among the best four third-placed teams, who get last 16 spots.
"We did not back down even after Ghana equalised. We always believed we could achieve a famous victory for our nation," said Comoros coach Amir Abdou, who has been in charge since 2014.
"I sent on attacking players in the belief that we could score a third goal and my decision paid off. Now we must wait to see if we are among the best four third-placed teams and play in the second round.
"We are satisfied with the way we played. We had a plan and stuck to it. We learnt from the mistakes we made in previous games. Obviously, I'm unhappy that we conceded twice, but we will improve."
A disastrous night for Ghana started after just four minutes when Serbia-based El Fardou Ben Mohamed fired the first-time qualifiers in front.
Mogni, who plays for French third-tier club Annecy, added a second just past the hour only for 10-man Ghana to hit back through goals from Richmond Boakye and Alexander Djiku.
Mogni struck again when he pushed a low cross from Ben Djaloud past goalkeeper Joseph Wollacott to give the islanders a stunning triumph.
Ghana had come to Cameroon confident of going far having pipped South Africa to secure a place in the final African qualifying round for the 2022 World Cup in Qatar.
A team coached by Serbian Milovan Rajevac included three Premier League players, Leicester City defender Daniel Amartey, Arsenal midfielder Thomas Partey and Crystal Palace forward Jordan Ayew.
Despite losing to Morocco and conceding a late equaliser against Gabon, Black Stars' supporters were confident of beating Comoros and, at worst, qualifying as one of the best four third-placed sides.
But after falling behind so early in northwest Cameroon, disaster struck on 25 minutes when Ayew, the son of Ghana legend Abedi 'Pele' Ayew, was shown a red card.
It was harsh call as Ayew unavoidably slid into Comoros goalkeeper Ben Boina, who had let the ball slip from his grasp.
After falling further behind, Ghana exposed a Comoran weakness when defending corners and a Boakye header and a Djiku tap-in raised hopes of a dramatic victory.
The islanders refused to panic, however, pressed forward and Mogni was among several Comorans lining up to push the cross over the goalline.
In Yaounde, Gabon led twice through Jim Allevinah and a Nayef Aguerd own-goal while Sofiane Boufal and Achraf Hakimi netted for Morocco.
Gabon had to line up without their three stars -- Arsenal forward Pierre-Emerick Aubameyang and Mario Lemina and Denis Bouanga from French clubs Nice and Saint-Etienne -- due to Covid-19.