A woman reduced to a minimally conscious state by a viral illness should not be permitted to die because her life retains "positive elements", a judge has ruled.

The landmark case at the court of protection sets a precedent for future applications to withdraw treatment from patients who are chronically medically dependent. It is thought to be the first time a judge has ruled on a case involving someone who is minimally conscious as opposed to being in a persistent vegetative state.

The woman, now 52, and legally known as "M", as her family does not wish to be identified, had been due to go on a skiing holiday in February 2003 when her partner found her slumped in a "drowsy and confused condition".

She was taken to hospital and diagnosed with viral encephalitis, which has left her with extensive and irreparable brain damage; for the past eight and a half years she has been fed by a tube.

Her family applied in 2007 for her artificial nutrition and hydration treatment to be stopped because they believed she would not want to live "a life dependent on others".

But a lawyer appointed by the high court to represent her opposed the relatives' application for nutrition to be withdrawn – arguing that she is "otherwise clinically stable". The local health authority, responsible for commissioning her care, also opposed the application.

"I accept that her life has a number of negative aspects, but I also find that it has positive elements," the judge explained. "I accept the evidence of the carers, who have far greater experience of living with M in recent years than do members of her family whose visits have become less frequent as time has gone by."

Most of the carers, he said, believed that treatment should continue. He added: "M does have positive experiences and …although her life is extremely restricted, it is not without pleasures, albeit small ones."

The judge praised the family for their support. "I acknowledge the devotion to M demonstrated by her sister B and partner S, and also by her mother W, who herself is now sadly in very poor health.

"After pursuing this litigation for years, I know that B and S will be extremely disappointed and probably distressed by my decision. I am sure, however, that they have M's best interests at heart, and I hope that they will be able to contribute to the process of making further decisions about her welfare."

Lawyers for the family said that the law had now been clarified.

"All parties agree that M's family have demonstrated their love and devotion for her throughout this case, and that they brought this application to court in what they perceive to be her best interests," said Yogi Amin of the law firm Irwin Mitchell. "The past eight years have been extremely heart-breaking for them all.

"They love her dearly and want only what is best for her, and it has been desperately difficult for them to make this application to court for treatment to be withdrawn. They believe that M was clear that she would not have wanted to live in the condition that she is in.

"However, the judge has decided in this particular case, after considering all the evidence that balancing the benefits and disbenefits to M, does not fall on the side of withdrawing treatment."

During the case evidence was heard that M was unable to communicate consistently, unable to mobilise or care for herself in any way, suffered pain, distress and discomfort regularly, and that after eight years there was no evidence that her condition had improved.

In his judgment, Baker also draw attention to the fact that the family had to rely on pro bono work by lawyers to represent them. "There are many demands on the restricted legal aid budget, but consideration should be given to extending the right to non-means tested public funding to family members seeking to bring this type of application," he said.