RECIFE, Brazil -- The United States reached the knockout stage of consecutive World Cups for the first time, just not the way the Americans wanted.

Germany beat the U.S. 1-0 on Thursday in soggy conditions on Thomas Muller's 55th-minute goal to win Group G, but the Americans advanced as runners-up when Portugal defeated Ghana 2-1 in a game played simultaneously in Brasilia.

The Germans, three-time World Cup champions, finished with seven points, while the U.S. had four after allowing a 95th-minute goal against Portugal on Sunday in a 2-2 draw. Portugal also had four, but the Americans advanced from a so-called "Group of Death" because their goal difference was even and the Portuguese were minus-3.

In the round of 16, the U.S. will face Belgium at 4 p.m. ET on Tuesday (ESPN/WatchESPN).

"This is a huge huge step and now we can't wait until round of 16," U.S. coach Jurgen Klinsmann said after the match. "Everyone said we had no chance, we took the chance and move on. And now we really want to prove a point."

Muller moved level with Lionel Messi and Neymar at the top of the World Cup scoring charts with his fourth goal.

The Bayern Munich midfielder scored his ninth goal in as many World Cup appearances 10 minutes into the second half. Per Mertesacker's header was pushed out instinctively by U.S. keeper Tim Howard, but the ball fell out to Muller, who picked his spot in the bottom right-hand corner of the goal from the edge of the penalty area.

Thomas Muller's second-half goal helped Germany top Group G.

Germany controlled much of the game, deservedly taking the three points to top Group G with two wins and a draw.

Straight into their possession-based game, Germany had the U.S. on the back foot for 10 minutes before Klinsmann's men were finally able to get their feet on the ball for a prolonged spell.

The respite was only brief, though, as Germany once again started to dictate proceedings before, on the break, Graham Zusi went the closest to breaking the deadlock with a curling effort over the crossbar.

Mesut Ozil had Germany's best chance of the first half, shooting straight at Howard as Germany were unable to make the most of their apparent superiority.

Germany's all-time top goal scorer, Miroslav Klose, was sent on at the start of the second half and he went within inches of connecting well with Bastian Schweinsteiger's cross, but all he could do was flick the ball wide of Howard's post.

The Germans shifted up the gears to increase the pressure on the U.S. and, 10 minutes into the second half, they got their reward through Muller's goal.

Much had been made in the build-up of Germany's non-aggression pact with Austria from the 1982 World Cup, when they obtained the 1-0 result in Gijon which took both nations through.

Thoughts of them replicating that in Recife and allowing the USA to get the draw they needed to be sure of joining them in the last 16 were soon dismissed, though, as Joachim Low's men showed no sign of letting up.

They could not find the second goal, though, and Philipp Lahm had to produce a last-minute block to preserve the win.

Jermaine Jones and the U.S. fought through the rain but saw little possession against Germany.

The Americans sprinted out onto the field at the final whistle, about 30 seconds before the other game ended and made advancement official. Brad Davis raised both hands and led the applauding U.S. team to the side of the stadium where the majority of American supporters sat.

"Well, we got through the group," Klinsmann said. "But we have to do better in the round of 16, and we will do better."

Just reaching Arena Pernambuco was an accomplishment. A tropical downpour flooded roads in a beach city known as the Brazilian Venice, and the U.S. bus had to make its way through ankle-to-thigh-high water that slowed traffic and left some cars stalled.

Rain fell throughout much of the game, and there were scattered empty red seats.

"I'm proud of the group and we still got a lot left in us," said Howard, who had five saves. "Today was a tough game, tough conditions.Hats off to Germany. I think they have a chance to win the World Cup that's how good they are. We had a chance there at the end. We get to the round of 16 it shows how far we've come, that we're not happy just getting there, that we want to progress and we still got a little bit left in us."

The game marked meetings of several former international teammates facing each other, an unusual occurrence. American right back Fabian Johnson started for Germany in the 2009 European Under-21 Championship alongside three of Germany's starters Thursday: Mats Hummels, Jerome Boateng and goalkeeper Manuel Neuer.

Klinsmann starred for West Germany when it won the 1990 World Cup and coached his homeland to the 2006 World Cup semifinals. His top assistant that year was Low, who succeeded him as Germany's coach after the tournament. The two exchange a hug after the final whistle.

There had been fears before the match that the U.S. and Germany would not attack each other too much and be satisfied with a draw, which would advance both nations. The Americans never came close to scoring until second-half stoppage time.

The script was similar to 2002, when the U.S. opened with a 3-2 win over Portugal, then tied South Korea 1-1 and lost to Poland 3-0. The Americans advanced 12 years ago because South Korea defeated the Portuguese on an 80th-minute goal.

With the U.S., Mexico and Costa Rica all advancing, CONCACAF -- FIFA's region for North and Central America and the Caribbean -- has three teams in the World Cup knockout round for the first time.

Information from The Associated Press and Press Association was used in this report.