A Montgomery Circuit Court judge on Thursday overturned the county’s ban on the use of cosmetic pesticides on lawns, dealing a major setback to environmental advocates who had argued that chemicals in the products are unsafe.

Judge Terrence McGann said that in Montgomery County the law – the first of its kind for a major locality in the region – would conflict with federal and Maryland state regulations that allow the use of the pesticides. The case was just one example of Maryland counties’ “insatiable appetite to tamper with existing state laws,” McGann said.

Counties have also “tried to hijack a portion of the existing field of law” in areas including tobacco, guns and minimum wage, he said.

The law, passed by a divided County Council in 2015, was to take effect in 2018.

It bans pesticides that have been approved by the federal government but contain chemicals that some studies say may cause cancer. The law exempts agricultural land, gardens and golf courses, and does not prohibit the sale of lawn pesticides in the county.

A provision of the bill eliminating the use of herbicides and pesticides on certain county properties, which was not part of the lawsuit filed by a group of homeowners and pesticide companies, took effect in July.

Council member George Leventhal (D), the bill’s chief sponsor and a candidate for county executive in 2018, said he was “very disappointed” by McGann’s ruling, which he said “sets a worrisome precedent for the ability of local governments to protect their residents on vital issues of health and safety.”

The county has 30 days to appeal McGann’s ruling.

Timothy Maloney, an attorney for the plaintiffs, including Scotts Co., a major manufacturer of lawn-care products, called the ruling a “significant victory for consumer safety.”