Giovanni Trapattoni's team will face the Spaniards at Yankee Stadium on 11 June, the Football Association of Ireland confirmed on Monday.
The match will end a busy fortnight for the Republic, who take on England at Wembley on 29 May, Georgia in Dublin on 2 June and the Faroe Islands in a World Cup qualifier five days later.
Trapattoni said: "I am looking forward to playing this match in New York. Our team is in evolving and showing a lot of promise.
"The recent games demonstrated that our players have serious potential.
"Matches against opposition like England, Georgia and Spain are very helpful to that development and great preparation for our important competitive fixtures in June, September and October."
Football will also be on the menu at the home of baseball's New York Yankees on 25 May when Chelsea line up against Manchester City.