Match ends, Portugal 2, Ghana 1.
Cristiano Ronaldo's second-half winner gave Portugal a 2-1 victory over Ghana, but the result means that neither team progress to the World Cup's last 16.
Ghana defender John Boye gifted Portugal the lead when he turned a cross into his own net, but Asamoah Gyan headed in an equaliser.
Ronaldo capitalised on a poor clearance to sweep home and give Portugal hope.
But they could not find the three more goals they needed to prevent the United States advancing on goal difference.
The USA lost to Group G winners Germany 1-0 in the section's other game.
Ronaldo's goal was his first in what was ultimately a disappointing tournament for a player who had scored 51 times in 47 appearances for Real Madrid last season.
The 29-year-old, who has suffered from knee and thigh injuries, failed to replicate the influence he had at club level as Portugal lost heavily in their opening group game against Germany, before a draw with USA left them needing to win by a large scoreline against Ghana to progress.
Ronaldo was given the freedom to roam across the Portugal frontline against the African side and, initially, he was at the centre of their best chances.
First, he almost caught out scrambling Ghana goalkeeper Fatawu Dauda with an audacious chip that smacked the crossbar, before his close-range header from Joao Pereira's pinpoint cross was instinctively batted away by Dauda, who turned and roared in delight at the Ghana fans behind his goal.
His joy, though, was short-lived, as Ghana conceded an unfortunate opener midway through the half.
Joao Moutinho fed Miguel Veloso on the left and he delivered a teasing cross that Ghana centre-back Boye deflected into the top corner of his own goal with his thigh.
While Portugal's problems have solely been on the pitch, Ghana's preparations were hampered by chaos behind the scene.
Midfielders Sulley Muntari and Kevin-Prince Boateng were expelled from the squad for alleged indiscipline - although Muntari would have missed the Portugal game anyway through suspension after picking up yellow cards in their first two games - while players had even threatened to boycott the Portugal fixture because of a row over appearance fees.
|Portugal won for only the second time in their last 10 World Cup matches|
|Asamoah Gyan (six) became the outright leading African World Cup scorer, going clear of Roger Milla|
|This match contained 35 shots (including blocked efforts). Only four matches in this tournament have contained more|
That was resolved on Wednesday and the Ghana players looked to have put it behind them as they pressed for an equaliser, only for wayward finishing from Christian Atsu and Gyan to prove their undoing.
For all their enterprising build-up play, it seemed Ghana would need a moment of magic to get back into the game.
That arrived just before the hour as Kwadwo Asamoah curled a stunning cross with the outside of his boot towards the far post, where Gyan was on hand to plant a header into the net.
With Germany leading the USA at the time, qualification suddenly became a realistic possibility for Ghana and they came agonisingly close to securing the win they needed when Majeed Waris flicked a header just wide from Gyan's cross.
However, Dauda ended his own side's hopes of securing victory when he pawed at a Portugal cross, clearing only as far as Ronaldo, who made no mistake.
Portugal coach Paulo Bento:
"It's not fair to blame individuals. We made mistakes as a team in the three matches - and I will never hold any individual responsible. We win and lose as a team.
"It's a tough time for us and we feel down as we all wanted to qualify for the Round of 16. We must now grow and advance so that we don't feel the same in 2016."
Portugal forward Cristiano Ronaldo:
"We created many opportunities but we could not finish them all. We knew we had to score three goals and we were depending on the result of the Germany game.
"We knew it was complicated but what's left at the end shows that it was possible considering the number of opportunities we created during the game."
Ghana coach Kwesi Appiah:
"It was a very exciting match with many chances on both sides.
"Unfortunately we didn't take ours and they took theirs."
- 22BetoSubstituted forDos Reis Carvalhoat 89'minutes
- 21da Silva PereiraSubstituted forVarelaat 62'minutes
- 6William Carvalho
- 2Bruno Alves
- 8João MoutinhoBooked at 90mins
- 11Macedo LopesSubstituted forVieira de Freitasat 69'minutes
- 17Almeida da Cunha
- 7Cristiano Ronaldo
- 1Dos Reis Carvalho
- 10Vieira de Freitas
- 13Moreira da Costa
- 15Ferreira da Silva
- 23AffulBooked at 39mins
- 17RabiuSubstituted forAcquahat 76'minutes
- 18WarisBooked at 55minsSubstituted forJ Ayewat 71'minutesBooked at 78mins
- 10A AyewSubstituted forWakasoat 81'minutes
- 12Larsen Kwarasey
- 13J Ayew
- Nawaf Shukralla
- Shots on Target
Second Half ends, Portugal 2, Ghana 1.
Attempt missed. João Moutinho (Portugal) right footed shot from outside the box is high and wide to the right.
Attempt missed. Asamoah Gyan (Ghana) right footed shot from outside the box is just a bit too high from a direct free kick.
João Moutinho (Portugal) is shown the yellow card for a bad foul.
Foul by João Moutinho (Portugal).
Asamoah Gyan (Ghana) wins a free kick in the attacking half.
Attempt missed. Nani (Portugal) right footed shot from outside the box misses to the left. Assisted by João Moutinho.
Attempt saved. Cristiano Ronaldo (Portugal) right footed shot from the centre of the box is saved in the bottom right corner. Assisted by Silvestre Varela.
Attempt missed. Cristiano Ronaldo (Portugal) left footed shot from very close range is too high. Assisted by Nani with a cross.
Corner, Portugal. Conceded by Harrison Afful.
Attempt missed. Asamoah Gyan (Ghana) left footed shot from outside the box misses to the right. Assisted by Jonathan Mensah following a set piece situation.
Substitution, Portugal. Eduardo replaces Beto because of an injury.
Foul by Vieirinha (Portugal).
Mubarak Wakaso (Ghana) wins a free kick in the defensive half.
Attempt saved. Asamoah Gyan (Ghana) right footed shot from the right side of the box is saved in the bottom left corner. Assisted by Christian Atsu.
Foul by Rubén Amorim (Portugal).
Mubarak Wakaso (Ghana) wins a free kick in the attacking half.
Foul by Silvestre Varela (Portugal).
Kwadwo Asamoah (Ghana) wins a free kick in the defensive half.