Gov. Phil Murphy on Friday signed legislation making New Jersey the seventh state to enact a law permitting terminally ill patients to end their lives.

Murphy, a Democrat, signed the Medical Aid in Dying for the Terminally Ill Act in private. His office would not answer why the signing was not public. The law goes into effect in August.

He earlier indicated he would support the bill, but in a personal statement, Murphy — a lifelong Catholic — revealed that he wrestled with whether to sign the legislation. The state's Catholic Conference testified against the measure.

"I have concluded that, while my faith may lead me to a particular decision for myself, as a public official I cannot deny this alternative to those who may reach a different conclusion," Murphy wrote. "I believe this choice is a personal one and, therefore, signing this legislation is the decision that best respects the freedom and humanity of all New Jersey residents."

Patrick Brannigan, the executive director of New Jersey's Catholic Conference, disagreed. In a written statement, Brannigan said he understood the bill's supporters wanted to act out of compassion, but the measure fails that test.

"The finest expression of compassion is loving care that reduces or eliminates physical pain, psychological distress, depression and hopelessness - not providing someone with lethal drugs to end their life," he said.

Under New Jersey's law, only patients who are irreversibly terminally ill and have a prognosis of six months or less to live could acquire medication to end their lives.

Lawmakers have tried since at least 2012 to advance the legislation.

The effort got some attention in New Jersey in 2014 when a 29-year-old California woman drew news coverage after she and her husband moved to Portland, Oregon, so she could use that state's law to end her life on her own terms. Brittany Maynard, 29, was terminally ill with brain cancer.

Her husband, Dan Diaz, praised New Jersey on Friday, saying residents wouldn't have to leave their homes "to secure the option of a gentle dying process."

Oregon in 1997 was the first state to provide an end-of-life option. California's law went into effect in 2016.

The New Jersey legislation includes measures that legislators called "safeguards."

The law requires that two doctors sign off on the request, that the patient be deemed an adult resident of New Jersey, who can make such a decision and who voluntarily expresses a wish to die.

It requires patients to request the medication twice and says they must be given a chance to rescind the decision. At least one of the requests must be in writing and signed by two witnesses.

At least one witness cannot be a relative, entitled to any portion of the person's estate, the owner of the health care facility where the patient is getting treatment or a worker there, or be the patient's doctor.

Under the law, patients must administer the drug to themselves, and his or her attending physician would be required to offer other treatment options, including palliative care.

Supporters say the law lets qualified patients decide to end their lives in a dignified manner.

Opponents, including the state's Catholic Conference, say that the measure hurts the most vulnerable, and the state should instead work to improve its health care system.

"With the signing of this bill to legalize assisted suicide, many vulnerable New Jerseyans are now at risk of deadly harm through mistakes, coercion, and abuse," said Matt Valliere, executive director of the Patients Rights Action Fund, an advocacy group opposed to such legislation.

The measure passed the Democrat-led Assembly 41-33, with four abstentions. It cleared the Democrat-controlled Senate 21-16.

In addition to California and Oregon, Colorado, Hawaii, Vermont, Washington and the District of Columbia all have similar legislation. Montana does not have a law permitting medically assisted suicide for the terminally ill. However, a 2009 Montana Supreme Court ruling determined that nothing in state law prevented a physician from prescribing such a drug to terminally ill person.