Cameroon will face Egypt in the 2017 Africa Cup of Nations final after two second-half strikes saw off Ghana.
Both sides had gone close to breaking the deadlock before Michael Ngadeu-Ngadjui took advantage of atrocious defending from a free-kick to lash in the opener in the 72nd minute.
With seconds remaining Christian Bassogog sealed victory when he applied a deft finish to a counter-attack.
Ghana went close through Wakaso Mubarak and Christian Atsu.
Panathinaikos midfielder Wakaso tested keeper Fabrice Ondoa will a brilliant bending free-kick, and Newcastle’s flying winger Atsu saw his angled strike drift past Cameroon’s upright by inches.
Aside from those two chances, the Black Stars – who last won the competition in 1982 – underwhelmed against a side who were clear second favourites going into the match.
As for coach Hugo Broos’ Indomitable Lions, they are into their first final since they lost to Egypt in 2008.
“It is a real dream for us to get to the final,” said the Belgian coach.
“Ghana have more experience than us – look at what they have done in recent tournaments. But since the start of this tournament we have shown we keep going right to the end in every game.
“I am very happy, especially for the team. They are an exemplary group on and off the field and they deserve to be in the final.”
Their build-up to the match was clouded by a dispute between the team and the national association over pay, but on Gabon’s Franceville stadium pitch their focus rarely wavered from the task in hand.
Cameroon defended brilliantly, nullifying the threat of Andre Ayew and brother Jordan – and, later on, substitute Asamoah Gyan.
They also caused Ghana several problems at the other end.
Slavia Prague defender Ngadeu-Ngadjui was both a rock in defence and a menace on set-pieces in attack, highlighted when he fired in from the angle to give his side the lead.
A free-kick was swung into the area and both Ghana defender John Boye and keeper Razah Brimah flapped at the delivery, allowing Ngadeu-Ngadjui to thrash home.
As Ghana, coached by former Chelsea boss Avram Grant, searched for the equaliser they left space at the back, which was exploited in the third minute of stoppage time when Aalborg forward Bassogog sprinted into the area and poked in past the reach of Razak.
“I am more than unhappy. We wanted so much to be in the final,” said Grant.
“We did everything to be there and in the second half we completely dominated. Congratulations to Cameroon of course but we were the better side and we lost.”
The Black Stars will meet Burkina Faso in Saturday’s third place play-off in Port Gentil.
Join GhanaStar.com to receive daily email alerts of breaking news in Ghana. GhanaStar.com is your source for all Ghana News. Get the latest Ghana news, breaking news, sports, politics, entertainment and more about Ghana, Africa and beyond.