SACRAMENTO — Everyone agrees California badly needs more housing. Few dispute that creating homes near mass transit would take pressure off jammed freeways. Building up, not out, has plenty of support among anti-sprawl environmentalists.

State Sen. Scott Wiener, D-San Francisco, is trying to deal with all three topics in one big bill. But he’s finding that when it comes to development, there’s no such thing as a mom-and-apple-pie proposal — not when it gives the state a major say over what kind of housing can be built on cities’ neighborhood streets.

Wiener’s bill would strip local governments of their ability to reject taller and denser apartment and condominium buildings if developers want to put them near public transit stops. Its supporters say it would prevent obstructionist NIMBYs from standing in the way of housing solutions. Opponents foresee low-income people being pushed out of neighborhoods to make way for structures that turn surviving small homes into something out of the movie “Up.”

“The bill has definitely struck a nerve,” Wiener said. “I knew it would be a controversial and hard bill, but I didn’t anticipate this level of focus.”

His SB827 would require cities to allow four- to eight-story apartment and condo buildings in residential areas if they are within a half mile of major transit hubs, such as a BART or Caltrain station. It would also mandate that cities allow such buildings within a quarter mile of highly used bus and light-rail stops.

The new height standard would depend on the size of the street. Buildings on narrower neighborhood byways would be limited to four or five stories, while eight-story structures could go up on major thoroughfares such as San Francisco’s Van Ness Avenue.

All other local zoning laws would remain in place, including affordable housing requirements.

Wiener says the bill is intended to deal with “the heart of our affordability crisis” in California — a shortage of new housing, especially in areas where people are being attracted by the tech industry. “California’s housing deficit is approaching 4 million homes, and it goes up by 100,000 a year,” Wiener said.

Tech executives whose companies are bringing in those workers are some of the bill’s strongest supporters. More than 100 executives, including Marc Benioff of Salesforce, Alexis Ohanian of Reddit, Jack Dorsey of Twitter and Logan Green of Lyft, signed a letter to Wiener saying California’s housing shortage is making it harder to recruit and retain employees.

“We recognize that the housing shortage leads to displacement, crushing rent burdens, long commutes, and environmental harm, and we want to be part of the solution,” they wrote.

Officials in cities whose height limits would be wiped out by Wiener’s bill say the list of society’s ills caused by the housing shortage shouldn’t be their problem alone. The League of California Cities opposes the measure and encouraged its members to voice their objections.

Fairfax Mayor Peter Lacques told Wiener that his bill “obliterates the kind of local control and flexibility that is required for towns and cities.”

Orinda Mayor Amy Worth, whose city would be affected by Wiener’s bill by virtue of its BART station, said the legislation “would subvert, and potentially derail” community planning efforts.

The bill prompted a raucous debate at a San Francisco Board of Supervisors meeting this month, where public speakers variously referred to it as an “undemocratic power grab” and a “hydrogen bomb” that will “blow San Francisco to bits.”

SB827 would apply to most of San Francisco, because 96 percent of the city’s residential parcels are within a half mile of a major transit stop, according to an analysis of the bill by the city Planning Department. San Francisco now limits construction in more than 90 percent of residential areas to four stories or less.

Besides raising those caps, Wiener’s bill would relax density requirements so more units could be built in each building.

“These are small to midsized apartments that we used to build all over,” Wiener said.

He argued that building more housing near mass transit would reduce not only traffic gridlock but California’s carbon footprint, helping the state meet its goal of cutting greenhouse gas emissions by 40 percent below 1990 levels by 2030. But the Sierra Club, one of the most influential environmental groups in the country, opposes it.

Michael Brune, executive director of the Sierra Club’s national organization, said he supports building more housing near public transit. But Wiener’s strategy of having the state override local control is heavy-handed, he said.

“We know that some members of the Legislature are working to refine the bill to make it less damaging in approach,” Brune said. “We hope they are successful, because we need more transit-oriented development that is appropriately sited to ensure smart, walkable communities that improve quality of life, reduce pollution and fight climate change.”

The Natural Resources Defense Council, another major environmental group, sent Wiener a letter Friday saying it supports the bill’s concept, but that it wants to work with him on “concerns that this approach could lead to further gentrification and displacement.”

Tenant groups that have long pushed for more housing are also expressing concern about Wiener’s bill.

Laura Raymond, campaign director of ACT LA, a coalition of tenant and housing groups in Los Angeles, said SB827 would hurt low-income renters who live near public transit. ACT LA’s fear is that developers would use the bill to ram through market-rate buildings, pushing out poorer residents.

“People are concerned about this bill,” Raymond said. “We’ve been trying very hard to get the right kind of policies passed.”

Wiener sought to defuse the argument by amending his legislation to let cities with rent control ban demolition of units covered by the price limits. He also agreed to stipulate that any tenant forced to move because of a project approved under SB827 could return to the property when it’s finished, at the same monthly rent. The developer would have to cover rental assistance during construction for up to 3½ years.

He’s won over a group of 22 California urban planning professors who cast the debate in anti-NIMBY terms, saying local governments are responsible for a “self-inflicted catastrophe.”

“Cities that block housing out of fears over congestion or aesthetics are prioritizing amenities for a lucky few over basic shelter for the many,” said the professors, most of them from University of California campuses. “By accident or intent, our local governments have created and presided over a massive transfer of wealth: from renters to owners, from the poor to the rich, and from the young to the old.”

The bill will face its first hearing in the Capitol next month.