SACRAMENTO, Calif. (AP) — Gov. Gavin Newsom used a new law for the first time Friday to try to force a wealthy Southern California coastal city to end its years of opposition to meeting low-income housing goals.

Newsom’s administration sued the Orange County city of Huntington Beach under the law that took effect Jan. 1 after passing in a 2017 package of measures intended to alleviate the state’s severe housing shortage and homelessness problem.

California has more homeless people than any other state and the nation’s highest poverty rate when soaring housing and rental costs are taken into account. Newsom, who took office this month, has proposed building 3.5 million housing units in the state with nearly 40 million residents.

The lawsuit says leaders in Huntington Beach, home to about 200,000 people, have repeatedly refused to amend the city’s housing plan to add state-required low-income housing and are fighting a separate lawsuit by housing advocates. The city says it’s complying with state housing and zoning laws.

It’s the second major issue facing California that the self-styled “Surf City USA” is battling the state over. Huntington Beach also is challenging the sanctuary law that limits cooperation with federal immigration officials.

The city is in a traditionally Republican area that has been shifting more Democratic like the rest of California. State officials say housing negotiations began before Huntington Beach challenged the immigration law and the lawsuit isn’t retaliatory.

“Many cities are taking herculean efforts to meet this crisis head on,” the Democratic governor said in a statement. “But some cities are refusing to do their part.”

City Attorney Michael Gates said it’s following the law, pointing to a victory in a related lawsuit. An appeals court ruled in 2017 that cities like Huntington Beach that have their own charters can approve plans that don’t meet the state’s housing requirements and can eliminate sites zoned for affordable housing.

Former Gov. Jerry Brown signed a law last year closing what housing advocates described as a legal loophole for charter cities. Huntington Beach’s charter led an Orange County judge to rule that it isn’t bound by the state’s sanctuary law because it has greater autonomy to enforce local laws. The state has appealed that ruling.

Gates said the city has approved more than 2,500 new housing units since 2014, including about 100 low-income units, leaving the city about 400 units short of state goals for low-income housing.

Republican state Sen. John Moorlach, who represents Huntington Beach, criticized Newsom’s “heavy-handed litigation tactics that will divert the city’s time, energy and resources to respond to obstructive and otherwise frivolous lawsuits.”

Democratic lawmakers, including Senate President Pro Tem Toni Atkins of San Diego, praised Newsom for opening what she called “a new chapter for housing in California” against cities that “have flouted their legal and ethical obligations.”

Huntington Beach was deemed out of compliance in 2015, and state officials most recently notified the city in November that it was still breaking state law. California sued in Orange County Superior Court under the new law strengthening its ability to require local governments to meet housing goals.

The California Department of Housing and Community Development sets the number of new housing units that a region is projected to need to provide homes for all income levels.

The department says 90 percent of housing plans statewide are in compliance, while Huntington Beach is one of 51 cities and counties that are not.

Newsom said high housing costs and rents “are eroding quality of life for families across this state.” He said the problem is “an existential threat to our state’s future and demands an urgent and comprehensive response.”

He has promised several moves to increase affordable housing, including giving cities more money for housing shelters but taking away transportation money if they fail to meet their goals. The Democratic governor’s budget proposal seeks $1.75 billion to combat homelessness by encouraging new affordable housing.