The USA were beaten 2-0 by Costa Rica in San Jose to finish third in the standings while Mexico eased past El Salvador 2-0 in Mexico City to finish second overall.
Costa Rica finished qualifying in fourth place and will face New Zealand in a playoff for a World Cup berth.
Canada, who completed their successful qualifying campaign with a 1-0 defeat in Panama on Wednesday, had already qualified for the World Cup on Sunday.
Both the US and Mexico had all-but sealed qualification after wins on Sunday meant only a freak set of results in Wednesday’s final round would see either side relegated to a playoff place.
🇵🇦 1-0 🇨🇦🇨🇷 2-0 🇺🇸🇲🇽 2-0 🇸🇻🇯🇲 1-0 🇭🇳#WCQ | #WorldCup | @Concacaf https://t.co/1B0KRffrC7
— FIFA World Cup (@FIFAWorldCup) 1648697380000
Costa Rica needed to beat the US by six goals or more in San Jose to have a chance of qualifying.
Two second-half goals in eight minutes by Juan Vargas and Anthony Contreras raised hopes of a miracle for the home fans, but the United States regrouped to close out the game, qualifying ahead of Costa Rica on goal difference.
“I’m extremely proud of this group,” US star Christian Pulisic said after Wednesday’s defeat.
“It’s a bit of a weird feeling right now because I hate to lose so much. But I’m really proud and I can’t wait to go to the World Cup.
“It’s definitely been a roller coaster. It’s never easy to come down and play in these countries, we know that.
“We battled through most of it. And at the end of the day, we’re at the top three and we’re going to the World Cup so we should be proud.”
🇺🇸U-S-A 🇺🇸 U-S-A 🇺🇸The Stars & Stripes are back at the #WorldCup!#WCQ | #WorldCup | @USMNT https://t.co/xiL6ilPlzx
— FIFA World Cup (@FIFAWorldCup) 1648695324000
The United States qualification comes after their shock failure to reach the 2018 World Cup in Russia, when an upset defeat to Trinidad and Tobago shattered their campaign.
Gregg Berhalter’s side had put themselves into an almost unassailable position on Sunday after demolishing Panama 5-1 at home in Orlando thanks to a hat-trick from skipper Pulisic.
That result meant Costa Rica would need a massive win to overtake the Americans for one of the two remaining automatic qualifying places.
But the US kept ‘Los Ticos’ at bay for long periods during the first half to leave Costa Rica’s hopes dwindling rapidly.
The US almost took the lead early in the second half when Miles Robinson’s header from Pulisic’s free-kick was parried away by Costa Rica goalkeeper Keylor Navas, before Timothy Weah’s follow-up was blocked.
— U.S. Soccer MNT (@USMNT) 1648698324000
But after that scare it was Costa Rica who took the lead on 51 minutes when Vargas headed home a corner from Brandon Aguilera.
Eight minutes later Costa Rica doubled their lead when US goalkeeper Zack Steffen flapped at a free-kick to cede possession in a dangerous area. Jewison Bennette drove in a low cross and Contreras bundled in the finish from close range.
That, though, was as good as it got for Costa Rica, who were unable to make inroads against a resolute US defence.
Mexico ended their see-saw qualifying campaign with a victory which ensures they will continue their record of appearing at every World Cup since the 1994 tournament.
🇲🇽 V A M O S 🇲🇽It’s yet another #WorldCup qualification for El Tri! #WCQ | #WorldCup | @miseleccionmxEN https://t.co/5Qm6g9aXSl
— FIFA World Cup (@FIFAWorldCup) 1648695580000
Mexico took the lead when Uriel Antuna jabbed home from close range on 17 minutes after a rebound from a Nestor Araujo header.
Wolves striker Raul Jimenez then doubled the Mexican lead from the penalty spot to leave ‘El Tri’ on course for Qatar.
In Wednesday’s other qualifying game, Jamaica defeated Honduras 2-1.