Spain may be one of the world's top tourist destinations, but many people in its biggest cities have grown exasperated with Airbnb-style rentals.
And now, their city councils are taking action.
Airbnb and other peer-to-peer rental websites have for years been credited with enabling lovers of travel and culture to find new ways to explore foreign lands.
However, complaints have abounded in Spain that greedy landlords are throwing out long-term tenants in order to cash in on the tourist flow, and that the short-term leases are pushing up rent.
By introducing a slew of new rules, Madrid's leftwing city hall plans to make it impossible for short-term rental companies to rent out 95 percent of apartments in the Spanish capital by the end of the year.
To get a holiday rental licence homeowners will have to prove their property has a separate entrance from the rest of the building—a condition that is in most cases impossible to fulfil.
Homeowners who rent their primary residence for less than three months a year will be exempt.
"We are aware that this is a very restrictive condition, and that is our intention," Madrid's city councillor for sustainable urban development, Jose Manuel Calvo, told AFP.
He said certain Madrid neighbourhoods have reached "the same saturation level" as Barcelona, where a boom in holiday rentals has drained the city's housing supply and pushed up rents, sparking a backlash against tourists that saw protesters take to the streets.
There are now around 9,000 flats in Madrid that are rented out to tourists, six to seven times more than in 2013, Calvo said. Of these, about 2,000 operate without a licence.
In some buildings landlords have evicted all local residents in order to rent their flats to tourists for more money, Calvo explained.
"The consequence is that these neighbourhoods end up emptying out gradually, and this must be prevented. There is still time," he said.
Madrid city hall in January stopped issuing new licences for tourist apartments, and only plans to resume licensing once the new system is in place.
Other cities in Spain, the world's second most visited country after France according to the UN World Tourism Organization, are also facing a surge in the number of sharing economy short-term rentals, threatening hotel businesses.
In the Mediterranean port city of Valencia the number of peer-to-peer holiday apartments has soared by 30 percent since 2016.
While the situation is not as critical as in Madrid and Barcelona, the city's leftwing mayor wants a raft of new regulations to be approved by July.
"It seems important to have rules in place that, without stopping this model of the sharing economy, are compatible with cities' desire to preserve the spirit of their neighbourhoods, without becoming theme parks," the city's economic development coordinator, Julio Olmos, told AFP.
The plan is to apply the same laws regulating hotels to tourist rentals. In practice under the new rules, only apartments on the ground floor or first floor can be legally rented out to tourists.
In the old town centre the legislation will be even tighter. There, licences will only be awarded to flats in buildings specifically designated for holiday rentals.
To ensure the rules are respected, Madrid and Valencia plan to follow Barcelona's lead.
The Catalan city employs 40 people tasked with poring through holiday rental sites to ensure that properties have the proper licences.
Between mid-2016 and mid-2017 Barcelona city hall, headed by a former housing rights activist, ordered the closure of over 2,300 holiday rental flats.
Fewer than 750 have obeyed the order, with legal proceedings under way against those still resisting.
Airbnb has, however, removed 1,500 ads for unlicensed flats, helping to return the properties to the regular rental market.
Palma de Mallorca, capital of Mediterranean tourist destination the Balearic Islands, is going even further—it is poised to ban nearly all short-term rentals of private homes like those listed on Airbnb.
The island city saw the number of holiday flats jump 40 percent between 2013 and 2017.
The surge is blamed for a shortage of long-term rental apartments, forcing some locals and seasonal workers to live in vans and campsites in the summer because they can't find affordable housing.
Detached homes will be available to rent for tourists only if they are located near the airport, in industrial areas, or in buildings not designated for residential use.
Explore further: Singaporean Airbnb hosts fined over unauthorised rentals