San Francisco has a new idea about where to house residents: basements and garages.

Grappling with a housing shortage that has sent rents soaring 50% since the recession, city officials on Tuesday passed legislation allowing landlords to carve fresh apartments out of underutilized spaces, including storage areas and utility rooms.

City leaders for more than a decade have tried to allow for new units to be tucked inside existing buildings, arrangements sometimes known as in-law units. Until now those efforts have been met with opposition from groups worried about overcrowding and parking shortages.

But with a growing sense of urgency about housing affordability, the San Francisco Board of Supervisors approved the measure. It next goes to the mayor, who was expected to sign it.

“The whole in-law unit conversation was long viewed as the third rail of San Francisco politics,” said Aaron Peskin, a supervisor who co-sponsored the legislation. “Whether it’s a shift in thinking or an adjustment to the crisis at hand, it is a sea change.”