UPDATE: Walsh said he will sign the ordinance.

The Boston City Council today approved, 11-2, a proposed law that would bar investors from renting out apartments and condos on Airbnb and similar Web sites but which would let owners who live in two- and three-family houses - buildings with five or fewer units - rent out space 365 days a year.

Councilors Mark Ciommo (Allston/Brighton) and Frank Baker (Dorchester) voted against.

The measure now goes to Mayor Walsh, who has backed a ban on investor-owned units but who wanted to limit homeowners to renting out units to 120 days per year. The measure requires people who rent out units to pay an annual fee to the city and let their neighbors know - and requires the city to collect and publish data on short-term rentals.

Councilor Matt O'Malley (Jamaica Plain/West Roxbury) sought, unsuccessfully, to put the 120-day limit back in the proposed ordinance, saying the investor ban would push Airbnb units out of downtown neighborhoods and into outer neighborhoods, making them even harder for moderate-income renters to find a place to live. Councilor Michelle Wu (at large), agreed, saying she is concerned about a new class of "horizontal hotels" on entire blocks, maintained by intermediary companies that take over management of home-share units in exchange for a cut of the profit.

But Baker said there's no proof that would happen and led a successful 7-6 effort to strike keep the 120-day limit out. Councilor Kim Janey (Roxbury) said that would let some of her constituents make some much needed money - in some cases to help subsidize other tenants.

Baker, Campbell, Ciommo, Edwards, Flaherty, Janey and McCarthy voted against the 120-day limit; Essaibi George, O'Malley, Pressley, Wu and Zakim voted for. Flynn, who initially voted against, later changed his vote to yes.

Ciommo voted against the 120-day limit even though he agreed with O'Malley and Wu the result will be increased pressure in outer neighborhoods. But he said the answer was to instead allow a small number of investor-owned units to be rented out on home-share sites, to create competition between downtown and outer neighborhoods. And he said the horror stories about landlords evicting all their tenants to make ad-hoc hotels is better addressed through zoning changes. But his proposal was also rejected.

People who rent subsidized units and owners of units in designated "problem properties" or which have had more than a set number of code violations over six months would be barred from renting out space.

Exempted from the ordinance: Lodging houses, bed-and-breakfasts and investor-owned units specifically meant for institutional and business uses.

The council approved the measure despite an increasingly shrill campaign by Airbnb that featured attacks on Wu and attempts to get Airbnb users who live in Boston to complain to the councilors.