Obama was supposed to spend two days in Spain after attending a NATO summit in Warsaw earlier this week.
President Barack Obama will meet with the King of Spain and Spain's acting prime minister in Madrid on Sunday, but the trip that was meant to show solidarity with Europe has been overshadowed by violent events in the United States.
The visit is Obama's first to Spain as president. White House officials said it was important for Obama to make the trip, because Spain was the only major European country he had not traveled to during his term.
Obama was supposed to spend two days in Spain after attending a NATO summit in Warsaw earlier this week. At the summit, the United States, Spain and the other allied nations pledged to stand united in the face of threats from Russia and fall out from Britain's vote to leave the European Union.
But, after a sniper killed five police officers in Dallas on Thursday following the fatal shootings earlier in the week of two black men by police in Louisiana and Minnesota, the White House decided to cut the trip short so Obama could go to Dallas.
Plans for sightseeing in Seville and a town hall meeting with Spanish citizens were canceled. Instead Obama, who landed in Madrid late on Saturday night, will squeeze in sessions with King Don Felipe and acting Prime Minister Mariano Rajoy on Sunday.
He will also address troops at Naval Station Rota, before heading back to the United States on Sunday night.
In an interview with Spain's El Pais published on Saturday, Obama called Spain "an indispensable European partner."
"Spain is a strong NATO ally, we're grateful for Spain's many decades of hosting U.S. forces, and we're major trading partners," Obama said in the interview. "That's why the United States is deeply committed to maintaining our relationship with a strong, unified Spain."
Obama's visit to Madrid comes after Rajoy's conservative People's Party (PP) failed to win a parliamentary majority last month leaving the country in a political stalemate as the parties work to form a coalition government.