Cristiano Ronaldo scored his first goal of the tournament as Portugal beat Ghana 2-1 but both teams were eliminated from the World Cup as the United States held on to second place in Group G despite their defeat by Germany.
Starting the day on a point each, both teams knew they needed a victory to have any chance of progress and Portugal started strongly as Ronaldo hit the bar and sent a close-range header straight at goal-keeper Fatawu Dauda before Ghana's John Boye sliced a cross into his own net after 31 minutes.
Asamoah Gyan headed the equaliser from a lovely Kwadwo Asamoah cross 12 minutes into the second half and Abdul Majeed Waris missed the chance to put Ghana ahead when he headed wide from point-blank range five minutes later.
Ronaldo finally found the net in the 80th minute but Portugal, thrashed 4-0 by Germany in their opening game, needed a far bigger win to overhaul the Americans' goal difference.
Germany topped the group with seven points and play the Group H runners-up - probably Algeria, Russia or South Korea - while the second-placed US will face the Group H winners, likely to be Belgium. Portugal finished with four points and Ghana on one.