Community advocates and environmental groups wanted the court to rule that health and the environment should take precedence over oil and gas production.

Colorado state law does not allow regulators to make public health and the environment their top priority when setting rules for oil and gas drilling, according to the Colorado Supreme Court. In a ruling Monday, it said state law requires regulators to “foster” oil and gas production while protecting public health and the environment.

But the court says regulators must take into account whether those protections are cost-effective and technically feasible.

The ruling is a victory for the industry, but tighter state rules might still be ahead because Democrats now control the Legislature and the governor’s office.

Newly elected Gov. Jared Polis wants local governments to have more control over the industry, which could result in more restrictions on how close wells can be drilled to homes and schools.

Community advocates and environmental groups wanted the court to rule that health and the environment should take precedence over oil and gas production. That could have brought tougher rules on where companies can drill.

Oil and gas drilling is hotly debated in Colorado, which ranks fifth nationally in crude oil production and sixth in natural gas, according to the US Energy Information Administration.

The state’s most productive oil and gas field — which is also one of the 10 most productive in the nation — overlaps fast-growing communities north of Denver, triggering frequent disputes over the proximity of wells to neighborhoods. In 2017, two people were killed in a home explosion and fire blamed on a severed natural gas pipeline.

The debate has played out in the courts, at the ballot box and before the Oil and Gas Conservation Commission.

Voters have repeatedly defeated ballot measures to expand the minimum distance between wells and occupied buildings. The most recent defeat came last November, after the energy industry spent lavishly on ad campaigns that said the measure would kill jobs and throttle a lucrative industry.

The ruling came in a lawsuit filed by six young people who asked the Colorado Oil and Gas Conservation Commission in 2013 to require that energy companies show they would not harm human health or the environment or contribute to climate change before regulators issued a drilling permit. The commission refused, saying it did not have that authority.

A district court sided with the commission, but the Colorado Court of Appeals reversed the lower court in a 2-1 decision last year. Then-Attorney General Cynthia Coffman appealed to the Supreme Court.

The Colorado lawsuit is one of several nationwide in which youthful activists argue state and federal governments are threatening their futures by not doing enough to battle climate change and protect the environment.