SACRAMENTO — A contentious bill to increase the housing supply in California by boosting dense construction around public transit and in wealthy suburbs was defeated in the state Senate on Wednesday, potentially capping a yearlong battle over its fate.

The Senate rejected SB50, by Sen. Scott Wiener, D-San Francisco, on a vote of 18 “yes” to 15 “no,” following a nearly two-hour debate in which lawmakers split along geographic rather than partisan lines. The measure needed 21 votes to pass the 40-member house.

Supporters, including Senate President Pro Tem Toni Atkins, D-San Diego, had maneuvered for months to advance the bill, which they argued was a critical step to addressing the state’s severe housing shortage. Atkins was among several members who urged the Senate on Wednesday to keep the measure alive so negotiations could continue in the Assembly, where further changes could be made.

But it ultimately ran into opposition from lawmakers who expressed concerns that it would strip too much control from communities and did not provide enough affordable housing.

Wiener was granted reconsideration to take up the bill again Thursday, a final shot to get it out of the Senate, though such a motion is often a mere courtesy from colleagues.

“We’re going to do everything in our power to pass SB50 tomorrow,” Wiener said in a brief statement after the vote. The clearest path to advancing the measure would be persuading some of the senators who didn’t cast votes to side with him. Six senators abstained and one was absent.

SB50 would have eased the development of small- and medium-size apartment and condominium projects by raising height limits, removing density restrictions and reducing parking requirements.

Under the bill, cities could not have blocked residential buildings of at least four or five stories within half a mile of rail stations and ferry terminals, provided they met other local design standards.

The state would have designated “jobs-rich areas” — higher-income census tracts close to employment opportunities and good schools — under a zoning preemption for density limits and parking requirements.

A streamlined process to convert vacant plots and homes in residential areas to multifamily housing of up to four units would have essentially eliminated single-family zoning in California, except in small coastal communities and areas at high risk of fire.

Wiener said on the Senate floor that the bill would counteract “deliberate anti-housing policies” that California and cities had adopted for decades, driving up the cost of living, pushing residents farther away from their jobs and threatening the state’s diversity and climate goals.

“We’ve made a choice that the way a neighborhood looks, that views are more important than who’s actually able to live in the neighborhood,” Wiener said.

The proposal drew broad support from labor unions, business groups, the construction industry and even some environmentalists. Gov. Gavin Newsom expressed his commitment to passing the bill in some form this year.

But it faced enormous resistance from local governments worried about losing their ability to decide how their communities grow. A state senator sympathetic to cities’ arguments shelved the measure in his committee last year, prompting Atkins to intervene last week to move it onto the Senate floor.

Wiener amended his bill this month to address the concerns over local control, though it did little to subdue cities’ objections.

The new version would have given them two additional years, until 2023, to come up with their own plans to build as much housing as the measure would otherwise have required before subjecting them to its new standards.

SB50 sharply divided the Senate’s majority Democrats, who met for 2½ hours before the vote. The large contingent of Los Angeles legislators overwhelmingly voted against it, while Democrats from Northern California and the Central Valley mostly supported it. Among Bay Area lawmakers, Democratic Sens. Steve Glazer of Orinda, Jerry Hill of San Mateo and Bill Dodd of Napa voted “no.”

Several senators who represent coastal and suburban districts, which would potentially see the biggest changes, said they could not support SB50 because they believed it would make the housing crisis worse in their communities.

Sen. Bob Hertzberg, D-Los Angeles, argued that the bill would give developers an incentive to wait until the law took effect three years from now to pursue new projects under more favorable conditions.

Although finding a solution to the housing crisis is urgent, Hertzberg said, “getting it right is just as urgent.”

Democratic Sen. Henry Stern, whose home burned down in the 2018 Woolsey Fire, said the measure would force cities like those in his district, encompassing portions of Los Angeles and Ventura counties, to rebuild in the same risky areas that have been devastated by wildfires in recent years. He said California must put new housing in the “right backyards.”

“When the land is too dangerous, we have got to say no,” Stern said.

Prominent affordable housing and tenants rights advocates also came out against the bill, which would have required projects approved under the relaxed standards to set aside 15% to 25% of their units for low-income families. They said it would not generate enough affordable housing or protect against gentrification.

Sen. Holly Mitchell, D-Los Angeles, said it was the concern she had heard most often from her constituents.

“The issue of gentrification is synonymous with fear,” she said, “a core fear about: Can I afford to continue to live in my community? Will developers and speculators buy up the property around me and make my community look and feel different? Who will be my neighbors?”

Alexei Koseff is a San Francisco Chronicle staff writer. Email: alexei.koseff@sfchronicle.com Twitter: @akoseff