California Gov. Jerry Brown signed a controversial bill that allows terminally ill residents to legally take their own lives, but the law does not take effect until the end of the legislative session -- probably in mid-2016.

Brown, a Roman Catholic and former Jesuit seminarian, said the decision on whether or not to sign the legislation had been "gut-wrenching," the Washington Post noted. The governor said on Monday he sought counsel with a Catholic bishop, two of his own doctors and friends "who take varied, contradictory and nuanced positions," according to The Associated Press.

"In the end, I was left to reflect on what I would want in the face of my own death," the 77-year-old prostate cancer survivor said in what the AP dubbed a "rare personal message."

"I do not know what I would do if I were dying in prolonged and excruciating pain. I am certain, however, that it would be a comfort to be able to consider the options afforded by this bill."

Four other states -- Montana, Oregon, Vermont and Washington -- already have similar "right-to-die" legislation, and the issue had made headlines in California after Brittany Maynard, a 29-year-old California woman with brain cancer, earlier this year decided to move to neighboring Oregon.

Days before she took life-ending drugs, Maynard recorded a video message in which she told California lawmakers that terminally ill patients should not need to "leave their home and community for peace of mind, to escape suffering and to plan for a gentle death," the AP recalled.

Many religious groups and advocates for people with disabilities, however, strongly opposed the legislation, arguing that "right-to-die" laws conflict with Biblical teachings and can lead to premature suicide and coerced early death.

Nevertheless, the new law includes safeguards to protect patients against the latter scenario: Those wanting to die must be able to take life-ending medication themselves and do so with the approval of two doctors and after having submitted several written requests. Two witnesses also need to be present, and only one of them can be a relative.