MANAUS, Brazil – So close, yet so far away.

Only seconds from registering a win over Portugal and clinching a spot in the round of 16 in the World Cup, the United States surrendered a goal and was forced to settle for a 2-2 draw with Portugal on Sunday night.

Silvestre Varela headed a cross from Cristiano Ronaldo past Tim Howard five minutes into stoppage time to give the Portuguese a lifeline in the World Cup while leaving the Americans stunned at a hot and humid Arena Amazonia.

“Too long. Thirty seconds too long,” goalkeeper Tim Howard said. “We had one foot in the door, but there’s a small bit of disappointment.”

Seattle Sounders striker Clint Dempsey, the U.S. captain whose 81st-minute goal off his stomach had given the Americans a 2-1 advantage, agreed.

“Obviously we’re disappointed,” he said. “But at the end of the day you have to look at the positives. We got a point. We’re on four points now. This is going to go down to the last game and hopefully we’re going to get the job done.”

The Americans (1-0-1, four points) will have to get the job done against Germany in Recife on Thursday.

They need a win or a tie with Germany (1-0-1, four) to clinch a spot in the round of 16. Portugal (0-1-1, one), which kept its slim hopes alive, will meet Ghana (0-1-1, one) on Thursday as well. The U.S. can also advance regardless of its result if Ghana and Portugal tie their match.

Dempsey, who played without a mask after breaking his nose in the 2-1 win over Ghana on June 16, had thought he had scored the winning goal in the 81st minute as he pushed in a rebound of a Graham Zusi shot past goalkeeper Beto.

“I just tried to stay onside and when the ball came across just put it on my chest and I was happy that the linesman kept his flag down,” Dempsey said.

The game had plenty of twists of turns from early goals to comebacks to some vital saves by Howard.

“Crazy game,” midfielder Michael Bradley said. “We put so much into it.”

The U.S. endured a disastrous start in the fifth minute when a poor clearance gave Portugal a goal on a silver platter. Geoff Cameron tried to clear a cross and instead booted it to an unmarked Nani, who beat Howard from six yards.

The Americans plugged away before equalizing on Jermaine Jones’ 26-yard blast to the lower right corner in the 64th minute.

As the final seconds were ticking down, Bradley lost the ball to Varela at midfield. The ball eventually was worked to Ronaldo, who sent a right-wing cross to Varela, who headed past Howard.

“It’s a bummer for a moment that you have to swallow,” U.S. coach Jurgen Klinsmann said. “These finishes are very emotional for all of us, for the fans, the players and the bench. This is what the World Cup is about. You have to cross it off and move on.”

Dempsey tried to look on the bright side.

“We put in a good performance,” he said. “We played better than last game, moved the ball a lot better, created more chances and were just unlucky not to get three points. But, at the end of the day we got a point and we’re still looking good in the group.”