TRENTON, New Jersey — A federal judge is weighing whether to scrap a state law barring private religious cemeteries from selling headstones after the Catholic Archdiocese of Newark and the state clashed on Wednesday in court over the legislation.

U.S. District Judge Michael Shipp said from the bench in Trenton that he would issue a written ruling, expected early next year.

The dispute goes back to 2013, when the archdiocese expanded its inscription rights program, the proceeds from which it used to care for cemeteries. Under the program, the church offered the option for a headstone but retained ownership of it in perpetuity. The idea was that a bereaved family could write an inscription on a headstone but the church would care for the headstone going forward.

The Monument Builders Association of New Jersey, an advocacy group for people who make headstones and other funerary monuments, soon sued, arguing the church’s tax-exempt status and relationship with parishioners gave it an unfair advantage. The group lost in court.

New Jersey’s Democratic-led Legislature then enacted legislation, signed by Republican Gov. Chris Christie in 2015, that effectively outlawed the practice.

Arguing for the archdiocese, whose supporters in court included a handful of priests, was Jeff Rowes, an attorney for the libertarian-leaning advocacy group the Institute for Justice. Rowes argued that it was “irrational” for the court to permit the kind of regulation under the New Jersey law, pointing out that the state is allowed to sell “materially” similar items like plots and community mausoleums.

“That is the kind of contradiction that courts have consistently said that’s irrational,” Rowes said.

The state argued it has to meet a low constitutional threshold to show it has a basis for legislating on the matter.

Attorney Karen Confoy, representing a funeral directors group that was aligned with the state, argued that the court should reject the archdiocese’s request and that the Legislature is not obligated to regulate mausoleums and headstones the same way.

“This court cannot look at what the Legislature did and say, ‘You could have done better. You could have done something more rational,'” she said.

The archdiocese serves approximately 1.3 million Roman Catholics in Essex, Hudson, Union and Bergen counties. A spokesman, Jim Goodness, said it operates 10 cemeteries.