U.S. forward Clint Dempsey plays the ball against Costa Rica in the second half Friday night at Red Bull Arena. Vincent Carchietta (USA Today Sports)

HARRISON, N.J. — The U.S. national soccer team’s hopes of qualifying for the 2018 World Cup were thrown into jeopardy Friday with a 2-0 defeat to Costa Rica that left almost no room for error heading into the last three qualifying matches.

Seemingly back in stride after last winter’s coaching change, the Americans were poor in the defensive end and inefficient in the attack in falling into a third-place tie with Honduras in CONCACAF’s six-nation final round.

Three teams will earn automatic berths to Russia next summer, and with Costa Rica and Mexico pulling away from the pack, the United States will jostle with Honduras and Panama for the final spot. The fourth-place finisher will face a special playoff against an Asian team.

The Americans (2-3-2, eight points) will visit Honduras (2-3-2) for a Tuesday afternoon kickoff in boiling San Pedro Sula before wrapping up the schedule next month against fifth-place Panama (1-2-4, seven) in Orlando and at last-place Trinidad and Tobago (1-6-0). The Americans have a big advantage in the goal-differential tiebreaker with Honduras.

Late Friday, Mexico (5-0-2) qualified with a 1-0 victory over Panama.

“It’s all still in our hands and we’re ready to go down to the wire and get ourselves into the World Cup,” captain Michael Bradley said. “We’ve got three games to play like our lives depend on it, and we will.”

The United States hasn’t missed the World Cup since 1986, one of the longest successful stretches in international soccer. With Bruce Arena in charge, the Americans had gone unbeaten in 14 consecutive matches since January and won the Gold Cup in July.

On this night, though, they took a step backward.

“We didn’t make any plays that mattered,” Arena said. “We were probably outplayed in most positions on the field and made some critical errors and didn’t capitalize on some potential opportunities. We didn’t have a good night. Give Costa Rica credit: They outplayed us and out-coached us.”

Marco Ureña, who plays for MLS’s San Jose Earthquakes, punished the U.S. team’s brittle central defense by scoring in the 30th and 82nd minutes as the Americans lost two home qualifiers in a World Cup cycle for the first time since 1957. (They began the final round with a 2-1 setback against Mexico in Columbus, Ohio.)

“We’re going to have to have short memories,” defender Graham Zusi said. “We weren’t good tonight, we know that, but we can’t dwell on it. We’ve got to move forward.”

In the 29th minute, Costa Rica tried to pierce the U.S. resistance with captain Bryan Ruiz threading a pass through the heart of the defense to Ureña. The recipient’s footwork was off, dashing the opportunity.

A minute later, the same pair combined again. After Costa Rica won a header in midfield, Ruiz picked out Ureña and, with a succinct pass, split center backs Tim Ream and Geoff Cameron.

Instead of continuing his run through the middle, Ureña went wide on Ream, shifted gears and snapped an acutely angled shot from eight yards. Shifting his weight to protect the near post, goalkeeper Tim Howard was unable to recover in time as the effort beat him to the far corner.

Ticos supporters, making up about 25 percent of the 26,500 at Red Bull Arena, went nuts.

It wasn’t a good half for Ream or Cameron, who had never partnered together in central defense as part of a four-man back line.

Cameron made several poor passes out of the back and Ream didn’t seem in sync, at one point prompting Arena to slap his hands in disgust after the ball was played back instead of forward.

Christian Pulisic, 18, was a threat in the open field — when defenders weren’t stepping on his toes — but lacked precision in the penalty area.

Costa Rica (4-1-2) was deliberate in the second half, stalling the match and picking out opportune moments to counter. Defensively, the Ticos absorbed pressure and tracked back when the United States tried to beat them with long balls to Bobby Wood.

With the Americans laboring to sustain an attack, Arena summoned Clint Dempsey at the expense of a defender. The urgency and pressure rose.

In the 67th minute, Pulisic smacked an angled shot through traffic. Keylor Navas, Costa Rica’s Real Madrid goalkeeper, somehow kept track of the deflected bid and, after committing low, reached up with his right hand, then his right foot, to prevent the equalizer.

Navas was at it again in the 81st minute, stuffing Jozy Altidore deep in the box. A minute later, another terrible pass by Cameron led to the second goal. David Guzman intercepted the errant ball and supplied Ureña in a central channel for a low finish into the left corner.

Are the Americans worried about their predicament?

“We’re not,” Howard said. “It puts more pressure on us, but we’re right in the thick of it.”

U.S. notes: Altidore received his second yellow card of the competition and will miss the Honduras match. . . . With a 23-player maximum, defender Matt Hedges, midfielder Cristian Roldan and forward Chris Wondolowski weren’t in uniform. . . . Costa Rica will visit Mexico on Tuesday.