Spain has beaten the United States to become the world's second most visited country after France, reports the Daily Mail.

The Spanish Prime Minister Mariano Rajoy confirmed that his nation has seen a surge in tourism while speaking at an event during a visit to Italy.

He revealed how 82million people had visited Spain in 2017, a nine per cent increase from the previous year that came despite the Barcelona terror attacks and the political crisis in Catalonia.

Tourism earnings rose also 12 per cent to 87 billion euros (NZ$144 billion), the Prime Minister said in Rome while attending a summit on migration.

Advertisement

And Mr Rajoy praised the Spanish tourism sector's 'great effort' to become more competitive.

Arrivals in Spain beat records for the fifth consecutive year, despite the jihadist attacks in the Catalonia capital Barcelona and nearby Cambrils last August that left 16 dead.

Catalonia also remains in the grip of a secession crisis. Arrivals recovered after dropping off by five per cent year-on-year in October as massive demonstrations were staged following a failed independence bid.

The Madrid-based UNWTO is set to release its figures for 2017 on Monday.

Tourism has also benefited from a boom in renting flats out to tourists via web platforms such as Airbnb.

Tourists on the Barceloneta beach during a year of reccord visiting numbers. Photo / Raquel Maria Carbonell Pagola, Getty
Tourists on the Barceloneta beach during a year of reccord visiting numbers. Photo / Raquel Maria Carbonell Pagola, Getty

However, this has prompted a backlash in popular destinations such as Barcelona, Palma de Majorca or San Sebastian as locals complain of a drop in long-term rentals and rising prices.

In 2016, Spain welcomed 75.3 million visitors, just behind the United States with 75.6 million, while France - despite its own terror woes - easily remained the world leader with 82.6 million visitors, according to the UN World Tourism Organization (UNWTO).

However, international tourism to the United States shrank during the first five months of Donald Trump's presidency, according to the US International Trade Administration.

Arrivals fell five per cent in the first quarter and three per cent in the second quarter, official figures show.