Airbnb has promised to quit clogging up cities that are struggling with housing shortages.

The online home-sharing platform announced new restrictions on London and Amsterdam listings this week that bar homeowners from renting their places to visitors for more than 90 and 60 days a year, respectively.

Local law already contained those limits but city authorities have had difficulty enforcing them.

Airbnb's decision to fall into line could bring some relief to residents struggling with soaring house prices and rents.

London's severe housing shortage has pushed home prices sharply higher over the last few years, and rent have also seen steady increases.

Airbnb's growing popularity fueled concern that the supply of apartments was being further squeezed by owners choosing to rent their places to tourists and visitors, rather than residents.

"This action should help ensure London gains the economic benefits of tourism that Airbnb creates without putting pressure on our housing supply," said Tom Copley, a London politician in charge of housing issues.

Related: Meet the Airbnb police

Critics of Airbnb have long claimed that the service removes affordable housing from the market by turning rentable apartments into unofficial hotels. A drop in supply can mean higher rents for the remaining apartments, and hotel group are upset at the loss of revenue.

Berlin recently banned renting out entire apartments through Airbnb and similar services, in an attempt to prevent rents rising. San Francisco and New York have also been cracking down on the service.

Airbnb promised in late 2015 to work with big cities to ensure it wasn't exacerbating a shortage of long-term rentals.

Related: Top Airbnb places for business travelers

The average Airbnb host in London earns £3,500 ($4,400) by sharing their space for 50 nights a year. A typical host in Amsterdam earns €3,800 ($4,050) from 28 nights, while New York hosts make nearly $5,500 from 47 nights.