A 2-1 victory over Ghana was not enough to save Portugal's World Cup campaign as their target of a top-two finish in Group G and a place in the knockout stages fell agonisingly short.

An own goal from John Boye and a second-half Cristiano Ronaldo strike set Paolo Bento's men on their way to the win they needed, but although the United States were beaten by Germany in the other group match, Portugal were kept out of the qualification spots on goal difference - largely because of the 4-0 rout they suffered to the Germans earlier in the competition.

Ghana's hopes of advancing were also ended - with Asamoah Gyan scoring their reply in Brasilia - to cap a day to forget for the Africans, who had thrown key midfielders Sulley Muntari and Kevin-Prince Boateng out of the squad just hours before kick-off for disciplinary reasons.

Despite their World Cup fate being largely out of their hands, Portugal were determined to get the win they needed to keep their slim hopes alive and were unlucky not to be in front after five minutes when Ronaldo pumped in a cross-shot from the right wing which rattled the crossbar.

The Real Madrid star threatened again seven minutes later from a free-kick which was lifted over the wall but punched away by Ghana goalkeeper Fatau Dauda.

Ghana responded by launching a couple of attacks of their own but attempts to get the ball to dangerman Gyan were dealt with by the Portuguese defence.

But it was Bento's men who seemed the more likely to score and another chance went begging for Ronaldo after 19 minutes, when his point-blank header from Joao Pereira's cross was bettered by a class save on the line from Dauda, which the Ghana goalkeeper saw fit to celebrate once the danger had been fully cleared.

Ghana immediately worked the ball down the other end, where Gyan's shot was kept out by Beto's feet. And the Portugal goalkeeper made another contribution minutes later, getting his hands to a header from Gyan after the former Sunderland striker met a free-kick from Kwadwo Asamoah.

However, Portugal eventually found the goal they wanted after 31 minutes, although it was a fortunate opener. Miguel Veloso was the creator, whipping in a cross from the left which bounced horribly for Boye and resulted in the defender slicing into his own net.

Ghana responded to the challenge, with Christian Atsu's assist headed past the right post by Gyan before Atsu himself tried a curling effort from the left side of the area which fell just wide of the far post as the Africans sought an equaliser.

Yet it was Boye who almost added to his tally on the stroke of half-time, a goal which would have extended Portugal's lead as the Rennes defender sliced a ball into the area from Nani narrowly over the bar.

The Africans came out a stronger force after the interval and were finally level after 57 minutes thanks to a fantastic ball in from Asamoah, with the Juventus midfielder using the outside of his left boot to thump in a pass which Gyan finished with a neat header.

The goal was Gyan's sixth in World Cup finals and saw him become the all-time leading African goalscorer in the tournament, passing the previous mark set by Cameroon's Roger Milla.

Portugal were beginning to look vulnerable and better finishing from an unmarked Abdul Waris would have put Ghana in front shortly after the hour, but the forward failed to make the most of a floated cross in from Gyan and directed his header past the right post.

Instead it was Portugal who finally broke the deadlock 10 minutes from time. Again luck was on their side as Nani's cross was headed high into the air by Jonathan Mensah, with Dauda flapping at the ball and pushing it straight into the path of Ronaldo, who slammed home for his first goal in Brazil.

Portugal and Ronaldo should have added to their total, but the world played of the year was denied twice by Dauda and also turned Nani's assist over the top of the net as the opening rout to Germany proved their undoing.