Each night, people in apartments all over New York City are cleaning up, putting out fresh towels and clearing out — to rent their private space to strangers from around the world.

Thousands of city residents are using websites such as Airbnb.com to list apartments or rooms for as little as $35 a night, a phenomenon officials say is illegal in many cases, undercuts the hotel industry, avoids taxes and threatens apartment building safety.