Mr. Justice Wilkie gave the 72-year-old man 14 days to leave the Finchley Memorial Hospital in North London.
In addition he was also asked to pay Ģ10,000 towards the legal bill run up by Barnet Primary Care Trust in its battle to remove him.
The judge described the case as highly unusual as the elderly man was first admitted to the hospital on the pretext that he was suffering from mobility problems in December 2002.
But he has not required medical or nursing attention since then. But the surprising twist was added to case when the hospital authorities themselves agreed that he suffered from breathing problems, two extremely large bilateral hernias and left-sided foot drop.
But the judge said that experts say that surgery would be likely to have a poor prognosis and could be fatal.
A panel of experts says that he has to be cared for in a residential home and not in a hospital. But the man despite the judge's ruling occupied the much-needed hospital bed.