SAN JOSE, Costa Rica (AP) -- Mexico will play New Zealand for a spot in next year's World Cup despite losing 2-1 at Costa Rica on Tuesday night. The Mexicans advanced to the home-and-home series when the United States rallied with two late goals to win at Panama. That kept Mexico in fourth place at the conclusion of the CONCACAF final qualifying round with only 11 points, three ahead of Panama, which would have advanced by holding off the Americans. Mexico will host the first leg on Nov. 13 or 14 and play at New Zealand on Nov. 20. The Mexicans have made every World Cup since they were disqualified from the 1990 tournament for using an overage player at a youth event, but they sure cut it close this time. Goals by Brian Ruiz in the first half and Alvaro Saborio in the second gave Costa Rica the win. The Ticos already had qualified for Brazil 2014 and wound up second to the United States in the round. Oribe Peralta scored in the 29th minute for Mexico, which won only two games in the 10-game finals. One of those victories came last Friday night against Panama in the first match for new coach Victor Manuel Vucetich, and that was the difference for El Tri. ''We thought that we were out,'' Peralta said. Still, Mexico could be hard-pressed to beat the Kiwis and get to Brazil, especially if it can't find some offense. In 10 games, the Mexicans scored seven goals. ''We've got to reflect, and we have to do whatever it takes to make it to the World Cup,'' Peralta added. ''Things are not working as we wish.'' Ruiz put Costa Rica in front with a brilliant move, heading the ball to himself in the penalty area, then whipping his left leg around for a shot from 12 yards that goalkeeper Guillermo Ochoa had no chance of stopping. But four minutes later, Mexico struck. Javier ''Chicharito'' Hernandez broke free and was about to put the ball into the net when diving keeper Keylor Navas barely touched it away. But the ball went directly to Peralta, who sent it into the unguarded cage. With rain coming down for most of the second half, particularly late in the match, each side pressed for another goal. Costa Rica got it, putting Mexico on the verge of elimination, when Saborio was left alone in front of the net to powerfully head home a feed from the right wing by Christian Gamboa. El Tri pressed for a tying goal, couldn't find it, but was saved, ironically, by the U.S. rally in Panama. Lineups: Mexico-Guillermo Ochoa; Hugo Ayala, Jorge Torres (Isaac Brizuela, 74th), Miguel Layun, Rafael Marquez; Oribe Peralta, Jesus Zavala, Christian Arevalo, Carlos Pena; Javier Aguino (Giovani Dos Santos, 66th), Javier Hernandez (Raul Jimenez, 60th). Costa Rica-Keylor Navas; Michael Umana, Giancarlo Gonzalez, Johnny Acosta, Bryan Oviedo, Christian Gamboa; Celso Borges, Yeltsin Tejeda (Jose Cubero, 72nd) Christian Bolanos; Joel Campbell (Michael Barrantes, 77th), Bryan Ruiz (Alvaro Saborio, 49th).