He will head to Poland on July 7-9th for his fifth and last summit with NATO leaders before spending July 9-11th in Spain, a White House statement said.
Obama will also hold bilateral talks with Polish President Andrzej Duda to "reaffirm the American commitment to Poland's security, and exchange views on the broader security environment in Europe," it said.
"The visit to Spain, an important NATO Ally, will highlight robust security cooperation, a strong political and economic relationship, and longstanding people-to-people ties," the statement continued.
"The President's agenda in Spain will include meetings with His Majesty the King of Spain and the Acting President of Spain."
James Costos, the American ambassador to Madrid tweeted:
The visit will come less than a fortnight after Spain goes to the polls for the second time since December.
It will be President Obama's first visit to Spain, although his wife Michelle, and daughter Sasha came on holiday to Spain in August 2010.