Following the decision, Ecuador became the second Latin American country to authorize this procedure.
Seven of the nine-judge Constitutional Court panel voted in favor.
Thus, doctors who assist a terminally ill patient in choosing euthanasia are no longer subject to jail.
"The penalty of murder cannot be imposed on a doctor who performs an active euthanasia procedure in order to protect the right to a dignified life," the court ruled.
The case was brought in August by Paola Roldan, a patient with the neurological disorder ALS (amyotrophic lateral sclerosis).
In her complaint, Roldan challenged an article in Ecuador's penal code that criminalizes euthanasia as murder and carries a prison sentence of 10 to 13 years.
Paola Roldan, who is bedridden, told the court, "I want to die in peace. What I am going through is painful, lonely and cruel. This is not a death struggle. I know I'm going to die, it's just a struggle about how I'm going to die."
The court that examined Roldan's request ruled that "it would be unreasonable to impose a survival obligation on someone in this situation."
Colombia became the first Latin American country to legalize euthanasia in 1997.