Gov. Phil Murphy has signed legislation making New Jersey the seventh state to enact a law permitting terminally ill patients to seek life-ending medication.

New Jersey joins six other states and the District of Columbia that have similar laws once it goes into effect in August.

The Democrat signed the Medical Aid in Dying for the Terminally Ill Act on Friday in a private ceremony.

Only patients who are irreversibly terminally ill and have a prognosis of six months or less to live could acquire the medication to end their lives under the New Jersey law.

Lawmakers tried for years going back to at least 2012 to advance the legislation.

The legislation has several measures that legislators called "safeguards."

They include requiring patients to make two requests and allowing them a chance to rescind the request.