Sean St Ledger had hero status snatched from his grasp as the Republic of Ireland very nearly held Spain to a draw in New York.
The reigning World and European champions were leading through substitute Roberto Soldado's 69th-minute strike when central defender St Ledger stabbed home what he thought was an equaliser with nine minutes remaining.
However, an offside flag against team-mate Simon Cox cut short his celebrations and those of the Irish contingent among a crowd of 39,368 at Yankee Stadium. Juan Mata made sure of the win two minutes from time, but while there was no doubting his side were worthy of their advantage after dominating much of the contest, Ireland, who also went close to levelling through substitute James McClean, left the pitch aggrieved at their misfortune.
It took two minutes and 52 seconds after kick-off for Republic keeper David Forde to become the first Irishman to get a meaningful touch of the ball.
As Xavi, Pedro, Andres Iniesta, David Silva and David Villa went through their full range of tricks, Ireland deployed their most effective weapons, bravery, commitment and organisation, and although there were several real scares along the way, they managed to get to half-time without conceding.
Indeed, they might have returned to the dressing room with an unlikely lead had Derby striker Conor Sammon been able to find a finish off a great opportunity. He looked odds on to score when he caught Gerard Pique, who had earlier seen a header cleared off the line by James McCarthy, in possession with 27 minutes gone and raced through on goal, only to prod his shot wide.
Del Bosque replaced Silva with Â£14.9million Manchester City new boy Jesus Navas at the break, but the pattern of the first half was largely repeated with Spain dominating possession and Ireland hanging on for dear life.
Spain came in wave after wave, but simply could not break down the Irish ranks with Forde coming from his line to pluck Pedro's 55th-minute cross off Villa's head after good work by Navas. Del Bosque shuffled his pack as the hour mark approached with Victor Valdes, Iniesta and Villa making way for Iker Casillas, Cesc Fabregas and Soldado.
McShane survived penalty appeals with Jordi Alba ambitiously claiming he had handled his 65th-minute cross, but Ireland were not so fortunate four minutes later. Full-back Alvaro Arbeloa turned up inside the box and prodded the ball towards Soldado, whose crisp volley flew beyond Forde and into the bottom corner.
Casillas pulled off a notable stop to turn Stephen Kelly's near-post header on to the bar, and when the ball came back off the post, St Ledger controlled and fired home only to have his big moment ruined by the officials. Worse was to follow when Mata, who had replaced Pedro in the immediate aftermath of the first Spanish goal, rubbed salt into the wound with a coolly-taken second two minutes from time to cement victory.