Maine legalized medically assisted suicide on Wednesday, becoming the eighth state to allow terminally ill people to end their lives with prescribed medication.

Democratic Gov. Janet Mills, who had previously said she was unsure about the bill, signed it in her office.

Oregon was the first state to legalize such assistance, in 1997, and it took over a decade for the next state, Washington, to follow suit. While still controversial, assisted suicide legislation is winning increasing acceptance in the United States, and this year at least 18 states considered such measures.

Maine's bill would allow doctors to prescribe terminally ill people a fatal dose of medication. The bill declares that obtaining or administering life-ending medication is not suicide under state law, thereby legalizing the practice often called medically assisted suicide.

The proposal had failed once in a statewide vote and at least seven previous times in the Legislature. The current bill passed by just one vote in the House, and a slim margin in the Senate.

The signing Wednesday was a relief to Mainers such as Staci Fowler, 47, who's taken on the fight for such laws in honor of her late friend Rebecca VanWormer.

VanWormer, whose breast cancer spread to her bones, had pushed for such a bill in 2015 — two years before she died in 2017.

"This is what she wanted," said Fowler, an educational consultant in Gardiner. "And now everybody has the option that she didn't have."

Maine joins seven other states and Washington, D.C., that have similar laws, according to the Death With Dignity National Center and the Death With Dignity Political Fund. The states are California, Colorado, Hawaii, Oregon, Vermont, Washington, and New Jersey, whose governor signed the legislation earlier this year.

Montana doesn't have a specific law on the books, but the state Supreme Court ruled in 2009 that doctors could use a patient's request for life-ending medication as a defense against criminal charges.

Maine's population has the oldest median age, and, as in other states, the proposal has exposed divisions that defied party lines.

Supporters, including Democrats and a small group of Republicans, say the terminally ill should have the right to choose a peaceful end.

Opponents, meanwhile, have said the legislation puts the terminally ill in "grave danger."

"Assisted suicide is a dangerous public policy that puts the most vulnerable people in society at risk for abuse, coercion and mistakes," said Matt Valliere, executive director of Patients Rights Action Fund, an advocacy group. "It also provides profit-driven insurance companies perverse incentives to offer a quick death, rather than costly continuing quality care."

The bill's Democratic sponsor said the latest language addresses criticism of past efforts that have failed in Maine.

The legislation defines "terminal disease" as one that is incurable and will likely end in death within six months.

The bill requires a second opinion by a consulting physician, along with one written and two verbal requests. Physicians would screen patients for conditions that could impair judgment, such as depression.

The law criminalizes coercing someone into requesting life-ending medication, as well as forging a request for life-ending medication.