The Black Stars had captain Andre Ayew sent off after 25 minutes and, after wiping out a two-goal deficit, lost when Comoros' Ahmed Mogni scored his second goal five minutes from time.
Minnows Comoros send Ghana crashing out of Africa Cup of Nations
Four-time champions Ghana were eliminated from the Africa Cup of Nations after crashing 3-2 to minnows Comoros in Group C on Tuesday in Garoua.
Morocco and Gabon drew 2-2 in Yaounde in the same group to retain first and second places respectively and qualify for the round of 16, which kicks off on Sunday.
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."
Serbian-born Ghana coach Milovan Rajevac said he would not resign despite his team finishing last with just one point.
"I came to Ghana to qualify the team for the World Cup. That is my primary target," he said.
"I will stay and lead the team in the March play-offs," he added.
A draw in Douala on Saturday will decide whether Ghana face Senegal, Morocco, Algeria, Tunisia or Nigeria in a two-leg play-off with the winners qualifying for the 2022 World Cup in Qatar.
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 World Cup.
The Black Stars 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 a 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.