Britain's highest court has ruled in favor of a hospital that gained court approval to withhold treatment from a terminally ill man despite the family's opposition.

In a unanimous judgment handed down on Wednesday, the Supreme Court ruled that the Court of Appeal was correct in allowing Aintree University Hospital in Liverpool to withhold treatment from David James, 68, who suffered colon cancer, organ failure and a stroke, among other problems.

James' doctors estimated he had a 1 percent chance of survival and applied to the Court of Protection for a legal declaration allowing it to discontinue some types of treatment. The court rejected the application on Dec. 6, but 15 days later the Court of Appeal reversed the decision. By that time, James' condition had worsened, and he died on Dec. 31.

James' family argued that his care should have continued.

The Supreme Court judges concluded that where treatment is futile, "it would be in the best interests of the patient to withdraw or withhold life-sustaining treatment," even if this results in the patient's death.

James' family said they believed he would have wanted to continue being treated and that he had not reached the point where treatment was hopeless. But lawyers for the hospital said James had severe physical and neurological damage, was steadily deteriorating and that further invasive treatments would put him at greater risk.

"When you can't consent, the law says we only treat you when it's in your best interests," said Penney Lewis, a professor and medical law expert at King's College London. She said British courts have previously ruled that preserving life is not always in the patient's best interests and that judges must weigh whether treatment would have any benefit for the patient, even if it doesn't cure them.

Though some treatments which result in minimal improvement might be considered worthy for some patients, such as those in intensive care, Lewis said that criterion wasn't met in James' case by the time the case went to the Court of Appeal, which ruled he had no chance of improving.

"The time had indeed come when it was no longer premature to say that it would not be in his best interests to attempt to restart his heart should it stop beating," the judges wrote in their decision.