Cristiano Ronaldo's first goal of the World Cup earned Portugal a 2-1 win over Ghana but couldn't prevent his team being eliminated from the tournament along with the Africans on Thursday.
Portugal finished level on four points with second-place United States in Group G but with an inferior goal difference. Germany topped the group after beating the U.S. 1-0 in Recife.
Ronaldo slammed in the winner with his left foot in the 80th minute to break his drought in Brazil and give Portugal its first win.
Ghana captain Asamaoh Gyan's 57th-minute header cancelled out an own goal scored by teammate John Boye in the 31st.
It was a bittersweet ending to the World Cup for Ronaldo, who has been nursing a left leg injury and seen the likes of Brazil star Neymar and Argentina captain Lionel Messi upstage him.
He barely celebrated his strike in the Brazilian capital, knowing his team still needed more goals — or a seismic turn of events in Recife — if Portugal was going to sneak into the last 16 at the Americans' expense.
Man of the Match
Cristiano Ronaldo was a force on the pitch and scored the winner. But being awarded man of the match will be of little significance to the world player of the year.
What this means
The result brought to an end a typically eventful few weeks in Brazil for the Ghanaians, who were part of thrilling games against the United States and Germany before their campaign ended in turmoil on and off the pitch.
Their players took to the field in the Brazilian capital amid a dispute with the country's football federation over alleged unpaid World Cup bonuses. Adding to the chaos, two of the team's star players — Sulley Muntari and Kevin-Prince Boateng — were booted out of the squad hours before Thursday's kickoff for disciplinary reasons.
For Portugal, their lop-sided 4-0 defeat to Germany in the opening match virtually sealed their fate. It was hard to overcome such a deficit in goal differential, giving the nod to the U.S in their second-place tie in the Group G standings.
Ghana finished bottom of the group.