(CNN) -

Mission accomplished -- Team USA booked its place in the last-16 of the World Cup after escaping from one of the tournament's toughest groups.

Jurgen Klinsmann's men slumped to a 1-0 defeat by Germany in Thursday's final Group G game but still qualified despite Portugal defeating Ghana 2-1.

Thomas Muller's second-half strike condemned the U.S. to defeat following a rain-soaked contest in Recife.

But Cristiano Ronaldo's late strike for Portugal inflicted defeat on Ghana and ensured the Americans qualified in second place on goal difference.

The U.S. will now travel to Salvador where its opponent will be Belgium on Tuesday, while Germany will face Algeria on Monday.

For Klinsmann, a man who won the 1990 World Cup as a player with West Germany and coached the national side to the semifinals in 2006, this was always going to be an emotional occasion.

Sitting on the U.S. bench just meters away from his old friend Joachim Low, the man who worked as his assistant eight years ago, the game had plots and sub-plots galore.

"We created too few chances, but it's still fantastic to go through," Klinsmann said.

"Everybody said we had no chance, but we've taken it and we're now in the last 16."

Any friendship or sentimentality was soon forgotten as the two teams went toe-to-toe in a heavyweight battle.

Played in monsoon-like conditions, both sets of players struggled to find any rhythm in the first half.

The buildup to the game was disrupted by heavy rain in Recife which left fans wading through flooded roads on the way to the stadium.

Traffic was brought to a standstill by floodwaters while family members of the U.S. team were unable to attend because of the adverse weather conditions.

Germany, which thrashed Portugal 4-0 in its opening game before being held 2-2 by Ghana, began in confident fashion and dominated possession.

But Team USA, marshaled by the impressive Omar Gonzalez, looked more than comfortable as the rain continued to lash down.

Despite being forced to sit back and soak up pressure early on, it was the U.S. which created the opening chance of the first half when Graham Zusi sent a curling effort just over the crossbar.

Germany, playing without a recognized striker, enjoyed plenty of possession in front of the U.S. defense but rarely managed to find a way through.

And when it did, goalkeeper Tim Howard was on hand to ensure Mesut Ozil's effort was blocked, after the Arsenal player momentarily eluded his marker.

Germany changed tactics after the interval with the introduction of veteran striker Miroslav Klose -- the man who stands joint-top in the World Cup goalscorers' chart with 15 to his name.

And it was the 36-year-old who almost made the breakthrough just minutes after interval but could only plant his header wide after meeting Muller's cross.

As Germany continued to push forward, the U.S defense began to drop deeper and deeper.

And with 10 minutes of the second half played, Germany finally got the breakthrough it had threatened.

Defender Per Mertesacker sent a thumping header towards goal and while Howard managed to beat the ball away, Muller fired home the rebound from the edge of the penalty area.

It was a magnificent strike from Muller, an effort which left Howard with absolutely no chance as it flew through a clutch of players and into the corner of the net.

It put the German joint top scorer at Brazil 2014 alongside home hero Neymar and Argentina's Lionel Messi.

Trailing by a single goal, news began to filter through that Ghana had moved level against Portugal, with Asamoah Gyan canceling out John Boye's first-half own-goal. Gyan is now Africa's all-time leading scorer at the World Cup with six, having passed Cameroon's Roger Milla.

With its future in the tournament hanging by a thread, the U.S. produced a battling performance with former Germany international Jermaine Jones and Kyle Beckerman snarling at the heart of the midfield.

But with 10 minutes remaining, Ronaldo's strike in Brasilia left Ghana with a mountain to climb -- though it wasn't enough to prevent an early trip home for Real Madrid's world player of the year.

That didn't prevent the U.S. piling forward in search of an equalizer though and both Alejandro Bedoya and captain Clint Dempsey came close to scoring at the death.

"We were dominant," said Muller, who scored five goals at the 2010 World Cup, where Germany lost in the semifinals.