Not even a last-minute Alan Judge winner could grab the headlines from the retiring John O’Shea as Ireland beat the USA 2-1 at the Aviva Stadium.

The international friendly would be the last time that Waterford native and former Manchester United defender O’Shea donned the green of Ireland and he bowed out following his 118th appearance in green.

The visitors threatened to spoil the party as they took the lead on the stroke of half-time, yet a spirited second-half performance from Ireland saw Graham Burke and the aforementioned Judge grab the goals to hand O’Shea a winning end to an illustrious international career.

It was a bright start from the home side as Martin O’Neill sent his side out in an attack-minded 3-5-1-1 formation, O’Shea sitting in the middle of the back three with Shane Duffy to his right and Kevin Long to his left.

West Ham youngster Declan Rice was tasked with anchoring the midfield three, while Shamrock Rovers’ attacking midfielder Burke made his first international start, sitting in the number ten position behind Jonathan Walters.

Callum O’Dowda and Walters - haring about like a man looking for a new club – set the tone for Ireland out of possession, putting immediate pressure on the USA rearguard, while Seamus Coleman wasted little time with his licence to move forward, racing into the opposition half inside the first five minutes.

An early corner led to a half-chance for Walters, while Burke was quick to banish any pre-match nerves, running onto a loose ball in the eighth minute before his goalbound effort was deflected for corner.

Another shot from distance, this time from Walters, had the keeper anxiously getting across his goal, however, the 11th-minute effort bounced wide.

Ireland’s best effort arrived in the 20th minute, as the ball was fed in from a throw-in on the right flank.

James McClean found himself in acres of space and had time to put all his might behind that left foot of his and sent a stinging, swerving effort goalwards.

Bill Hamid in the USA goal was taking no chances with punching or catching the incoming Derry-made missile but instead managed to parry the ball to diffuse the situation.

The USA, meanwhile, looked exactly like a team who failed to qualify for the World Cup. And despite their neat football out from the back, appeared disjointed and were struggling to work it into the final third.

If they are in a rebuilding phase, they may not even have begun to dig the foundations on this evidence. Tim Weah looking about their most potent threat, hugging the right touchline.

Yet two chances inside two minutes midway through the half showed that there was an attacking threat waiting to break out, as first, Tyler Adams smashed a breaking ball from the edge of the box, which looked to be on target but cannoned off his own player and over, before Bobby Wood had a chance a minute later, but his stinging, curling effort flew wide of the top corner.

After 34 minutes, the Lansdowne faithful bade farewell to a modern Irish footballing legend.

O’Shea was called home for the final time as the next generation set out to try to end the season on a winning note – Blackburn Rovers’ Darragh Lenihan replaced the Deise man who left to a standing ovation.

Burke blasted a free kick into the wall from the edge of the box after Callum O’Dowda was chopped down just outside the area four minutes from half-time.

But it was the USA who would take a shock lead into the break as Ireland were undone by a set-piece as the ball was hoisted deep into the box. And while Hendrick tracked his man back across the six-yard box, no one spotted Bobby Wood who guided the ball past the stationary Colin Doyle, who could do nothing about the point-blank effort.

Ireland set about making amends in the second half and following a sluggish start, parity was restored in the 57th minute as Burke wrote his name into the Irish scoring record books as he jabbed the ball home from mere inches.

A well-worked corner was pumped to Long at the back post and the Burnley defender guided the ball back across the goal for the waiting Lenihan. Neatly controlled on his abdomen and smashed goalwards, it should really have been a goal for the first Meath man to make a senior Ireland appearance.

But it was Burke with the final touch and the happy Hoop took the plaudits before departing the pitch a minute later as Daryl Horgan came on for the final 30-odd minutes.

Ireland, buoyed no doubt by the goal, appeared to step up a gear and maintained the pressure on the visiting side.

And O’Neill’s side should have gone ahead in the 68th minute as Lenihan – again – was denied a debut goal.

Another well-worked set-piece saw Lenihan time his run to perfection and guide a glancing header beyond Hamid into the far corner only for the goal to be deemed offside by the linesman on the far side of play, as he failed to spot the defender arriving from an onside position.

The game opened up and lost its shape to a certain extent as the usual plethora of substitutions entered the fray – including Enda Stevens making his international debut, as well as Alan Judge and Harry Arter.

But Ireland kept the momentum moving forward and were eventually rewarded with a winning goal as the clock entered the final minute of the 90.

Worked in from the right, McClean ran onto the squared ball and some neat footwork took him past the defender, which left him in a prime position to pull the trigger.

But on a night of goal-poaching, Judge gave the West Brom man no time to shoot as the Brentford Bee sent a stinging effort in off the underside of the crossbar to end the international season on a high for Ireland.

Republic of Ireland: Colin Doyle, Shane Duffy (Enda Stevens 77), John O'Shea (c) (Darragh Lenihan 34), Kevin Long, Seamus Coleman, Declan Rice, Jeff Hendrick (Harry Arter 82), Callum O'Dowda (Alan Judge 88), James McClean, Graham Burke (Daryl Horgan 58), Jon Walters.

USA: Bill Hamid, DeAndre Yedlin (Shaq Moore 70), Cameron Carter-Vickers (Tim Parker 21), Matt Maizga, Jorge Villafana, Wil Trapp (c), Tim Weah, Tyler Adams, Weston McKennie (Joe Corona 81), Rubio Rubin (Luca De La Torre 77), Bobby Wood (Josh Sargent 70).

Referee: Andrew Dallas (SCO).