Second Judicial District Judge Nan Nash said the constitution prohibits the state from depriving a person of life, liberty or property without due process.
"This court cannot envision a right more fundamental, more private or more integral to the liberty, safety and happiness of a New Mexican than the right of a competent, terminally ill patient to choose aid in dying," the judge wrote.
Nash also ruled that doctors could not be prosecuted under the state's assisted suicide law, which classifies helping with suicide as a fourth-degree felony. The plaintiffs in the case do not consider physicians aiding in dying a form of suicide.
The New Mexico Attorney General's Office said it is discussing the possibility of an appeal but needs to fully analyze the judge's opinion before commenting further.
Nash's ruling stems from a two-day bench trial in December in which two doctors and a Santa Fe woman with advanced uterine cancer asked the judge to determine that physicians would not be breaking the law if they wrote prescriptions for competent, terminally ill patients who wanted to end their lives.
Doctors Katherine Morris and Aroop Mangalik and patient Aja Riggs filed their lawsuit in 2012.
The lawsuit had the support of the American Civil Liberties Union of New Mexico, Denver-based Compassion & Choices and the New Mexico Psychological Association, the largest organization of professional psychologists in the state. The psychologists' group argued that assisted suicide and "aid in dying" for terminally ill patients were fundamentally different.
"New Mexicans, both healthy and sick, now enjoy the comfort and peace of mind that come with knowing they can prevent a prolonged, agonized dying process at the end of life," ACLU of New Mexico Legal Director Laura Schauer Ives said in a statement.
Riggs, a 49-year-old Santa Fe resident, has undergone aggressive radiation and chemotherapy treatment. She testified in December that her cancer was in remission but said there have been days when getting out of bed and walking 15 feet were an uphill battle.
Riggs said she wanted to live but also wanted the option of dying if her condition worsened.
"I don't want to suffer needlessly at the end," she told Nash during the trial.
Kathryn Tucker, director of legal affairs for Compassion & Choices, has said there's growing support for physicians to help terminally ill patients who want to end their lives.
Four other states, including Oregon, allow patients to seek aid in dying if their conditions become unbearable.
The New Mexico Conference of Catholic Bishops was disappointed with Monday's ruling, saying there's a difference between fundamental rights guaranteed by the constitution and the ability of someone to take a person's life.
Opinions can differ with regards to the survivability of illnesses, and medical treatments can progress, said Allen Sanchez, executive director of the bishops' group.
"As long as there is a chance for human error, we can't have that. You can never reverse the decision you've made. It's the finality of it," Sanchez said. "If we are not willing to give that ability to a judge and jury by doing away with the death penalty in New Mexico, we should not be willing to give one doctor and two witnesses that ability."