ALBUQUERQUE, N.M. — New Mexico has succeeded in a lengthy legal battle aimed at barring a horse slaughter operation from opening in the state.

A state District Court judge in Santa Fe granted an order late Thursday that finalizes a settlement reached with the attorney general’s office, animal advocates, Valley Meat Co. and other associated businesses.

Valley Meat had sought to convert its cattle processing plant in Roswell to the slaughtering of horses, but the state filed a lawsuit in 2013 in hopes of stopping those plans, saying such an operation would violate New Mexico’s environmental and food safety laws.

Bruce Wagman, an attorney for the horse advocacy group Front Range Equine Rescue, said Friday that the order and previous rulings from the judge effectively end any chance of a horse slaughter operation opening in New Mexico.

“This is the end,” Wagman said. “It can’t happen here in New Mexico.”

Blair Dunn, an attorney for Valley Meat, said the closure of the case means his clients will no longer be harassed by the attorney general’s office and the others who joined the fight.

Still pending is a federal lawsuit and a counter claim in state District Court in which Dunn’s clients are seeking a jury trial to decide damages for what he called a malicious use of the legal process.

“These groups used the process to destroy these people’s business,” he said.

During the legal wrangling, proponents had argued that domestic slaughter was the most humane way to deal with a rising number of abused and abandoned horses. Currently, unwanted horses are shipped to Canada and Mexico for slaughter.