Forty years ago, Barcelona wasn’t high on most tourists’ lists of must-see cities in Europe. But that changed after the city hosted the Summer Olympics in 1992: An enormous public investment in beautifying the city coincided with a prime spot on the global stage. A new “destination” was born.

Attracted by the city’s museums, restaurants, architecture and Mediterranean coastline, tourists arrived from across Europe and around the world. By 2019, Barcelona — a city of about 1.6 million — registered over 21.3 million overnight stays, more than double the figure from 2005. And that’s not even counting the more than three million cruise ship passengers who passed through the city’s port that year.

When Airbnb arrived in 2009, Barcelona had no specific regulations governing private rentals to tourists, but interest in the service was evident: By the middle of 2016, there were some 20,000 listings of both private rooms and entire apartments in Airbnb’s Barcelona section, according to data from Inside Airbnb, which tracks listings in cities around the world. The hosts in Barcelona were operating in a kind of “gray market” in those early years of growth: It wasn’t explicitly legal, nor was it clearly forbidden.

But as tourist numbers grew, so, too, did the sense among many in Barcelona that the city was nearing its capacity for visitors. In the summer of 2014, anti-tourism protests erupted in the Barceloneta neighborhood, where locals had grown frustrated with the noise and raucous behavior of visitors who had come to party. Anti-tourism graffiti sprouted up, sometimes in popular tourist spots, and in 2017, a group of left-wing activists vandalized an open-top bus filled with tourists. Many residents — as well as some at City Hall — pointed the finger at Airbnb.

“For a long time, tourism was seen as nothing but a positive thing for the city, but now we’re starting to feel all of the impacts,” said Mar Santamaría Varas, a Barcelona-based architect and co-founder of 300.000 Km/s, an urban planning agency. With regard to tourist accommodation, she added that her analysis has revealed three main problems: gentrification, crowding in public spaces, and the disappearance of corner stores and other retailers that are essential for residents.

Airbnb maintains that private room rentals have little to no impact on the availability of local housing, as people who rent out private rooms live in the same property. But a study published last year in the Journal of Urban Economics found that Airbnb activity in Barcelona has increased rents by 7 percent and housing prices by 17 percent in the neighborhoods that have the highest levels of activity on the platform. In the average neighborhood, the effects were a 1.9 percent increase in rent and a 4.6 percent increase in housing price.

The 2015 election of Ada Colau as Barcelona’s mayor marked a turning point in the city’s relationship with tourism, ushering in the first real efforts to regulate short-term rentals. Already famous in Spain for her work fighting housing evictions, the left-wing Ms. Colau took a much harder line on tourism than her predecessor. Under her leadership, City Hall enacted a moratorium on new tourist licenses for entire-apartment rentals; launched a major crackdown on illegal apartment listings; banned the construction of new hotels in the city center; and introduced neighborhood-specific rules to regulate the establishment of souvenir shops and other businesses that cater to tourists.