UNDATED (AP) — The U.S. was seconds away from earning a berth in the knockout stage at World Cup, clinging to a 2-1 lead deep into injury time against Portugal. But the Americans had to settle for a 2-2 tie as Varela scored on a header in the fifth extra minute to keep Portugal alive in the tournament.

The United States fell behind 1-0 just five minutes in and continued to trail until Jermaine Jones slammed a curling shot into the net in the 64th minute. Clint Dempsey put the Yanks ahead in the 81st minute, his second goal in two games. Dempsey's goal came on a cross from Graham Zusi,

Getty Images

who set up both second-half tallies less than a week after his late corner kick led to the game-winning goal against Ghana in the opener.

But the U.S. was unable to finish off Portugal. Playing despite a left knee injury, Cristiano Ronaldo sent in a cross that Valera redirected past Tim Howard.

The outcome leaves the U.S. and Germany in a first-place tie in Group G with four points, three ahead of both Portugal and Ghana. The Americans will face Germany on Thursday, while Portugal takes on Ghana at the same time.