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.
Almost 12 months to the day, Ireland succumbed to Spain at the Euro 2012 finals with barely a whimper as Vicente Del Bosque's men ran out 4-0 winners at a canter.
From the moment Fernando Torres put them ahead with just four minutes gone, there was never any prospect of the points ending up anywhere but in their back pocket, and the omens were far from promising once again.
It took a bewildering 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.
Spain, fielding an eye-wateringly strong team in their final warm-up game for the Confederations Cup in Brazil, moved the ball with customary ease to leave Giovanni Trapattoni's men chasing shadows.
But crucially, they managed to do what they had failed to in Poland and summon up the commendable resilience which had in large part earned them their ticket to the summer jamboree.
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 got 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 to match the effect of the scuffling which created his opportunity.
After a testing start, Andy Keogh had cleared Victor Valdes' bar with a 12th-minute volley and full-back Paul McShane did the same with a header two minutes later.
But Sammon 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 in on goal, only to prod his shot wide of the far post.
The scare prompted Spain to redouble their efforts and Pedro probably should have scored after McShane had diverted the ball into his path as Villa carved his way into the penalty area 12 minutes before the break.
Villa was denied by the advancing Forde after being played in by Silva six minutes later, but the Millwall keeper needed the help of the crossbar to keep out Pedro's left-foot piledriver.
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 Valdes, Iniesta and Villa making way for Iker Casillas, Cesc Fabregas and Soldado, but it was Navas and Pique who tested Forde in quick succession as his side pressed once again.
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.