MADRID : Barack Obama embarked on a shortened but symbolic first presidential trip to Spain Sunday, saying his crisis-hit ally had turned the economic corner.

Obama is squeezing in a visit to a key NATO and EU partner before dashing home to deal with the aftermath of a wrenching shooting in Dallas.

He has cut a two-day visit to the Iberian peninsula down to one and cancelled a trip to Seville with King Felipe altogether, after a black army veteran in Dallas killed five white police officers.

"I've been looking forward to visiting Spain, an indispensable European partner, even as the horrific shootings in the United States require that I cut my time here short," Obama told Spanish daily El Pais.

"I had a chance to travel through the country in my twenties when I was backpacking across Europe... I've always wanted to return."

Obama, who prides himself on his measured approach, is usually loath to alter carefully laid plans.

But the shooting - just blocks from the place where John F. Kennedy was assassinated - has pushed a country crackling with political tension to the edge.

Speaking in Warsaw just before Air Force One departed for Spain, Obama insisted the country's divisions were overplayed.

This was not, he insisted, the crisis-ridden days of the 1960s, when US cities burned, the Vietnam War raged and the Kennedy brothers and Martin Luther King were slain.

But his decision to shorten the trip is a tacit acknowledgement that the United States faces a combustible mix of deteriorating race relations, hyper-charged election politics and seemingly never-ending gun violence.

In recent months, the emergence of videos of deadly mass shootings, or of white police officers killing black civilians, have become routine.

Yet the refusal of America's first black president to scratch the trip to Spain entirely also reflects a determination to fulfil geopolitical goals.

Obama, who was greeted on arrival at Torrejon Air Base by King Felipe, will visit a US and Spanish Naval Station at Rota, in southern Spain, addressing US personnel who have been stationed at the mouth of the Mediterranean since a deal with Spain's former dictator Francisco Franco.

Since the time of the Greeks, Romans, Moors, Phoenicians and Visigoths, the Bay of Cadiz has been as a prime piece of geopolitical real estate.

Today, it has taken on renewed importance with the deployment of four US Aegis destroyers.

They form an integral part of a European missile defense system much despised by Russia.

The transfer of the system to NATO control was a key part of an alliance summit in Warsaw which stressed deterring Moscow from destabilizing eastern Europe.

Obama's visit comes as Spain remains mired in a months-old political crisis, with two general elections resulting in no clear victor.

The two centre-left and centre-right parties that have dominated Spanish politics since the return of democracy in the late 1970s have, in the face of insurgent leftists, so far been unable to form a government.

Obama will meet acting premier Mariano Rajoy as well as opposition leaders.

He will also hold talks with King Felipe at the royal palace, before heading back to the United States, a country that now seems as divided in its politics as Spain. But Obama has a positive note for Spaniards who have suffered years of grinding economic hardship. "Spain," he said, "has travelled a particularly difficult path in recent years."

He described the brutal blows of a twin financial and economic crisis, and austerity policies, which he said, had fueled political disconsent. But, he said "Spain has turned a corner."

"The economy is growing again, with growth rates that are among the strongest in Europe. There's new hope for the future."