The deeply religious parents wanted their son to be kept alive on a life-support system.
But a doctor said: "In my opinion Baby X no longer has the human instinct and desire to survive."
And a judge agreed, ruling that Baby X's life support can be switched off.
Mr Justice Hedley praised the parents' dignity and acknowledged that the baby's mother and father believed 'where there's life there's hope' but he said that the preservation of life by medics 'cannot be everything.
"No understanding of life is complete unless it has in it a place for death which comes to each and every human with unfailing inevitability," he said.
"There is unsurprisingly deep in the human psyche a yearning that, when the end comes, it does so as a 'good death'.
It is often easier to say what that is not, rather than what it is, but in this case the contrast is between a death in the arms and presence of parents and a death wired up to machinery and so isolated from all human contact in the course of futile treatment.
"My last words must be of profound sympathy to [the parents], whose loss and sorrow can I think only be grasped by those who also have passed through the valley of the shadow of death with their own children," he said.
In most cases where patients are not expected to recover from brain injuries or disabilities, relatives agree with doctors that life support can be switched off.
But when loved ones disagree, judges can be called upon to decide whether or not their wishes should override those of NHS trusts.Mr Justice Hedley quoted a consultant who said the baby 'lacks awareness of his surroundings', 'remains comatose', 'shows no interaction or recognition to his parents or carers' voice' and 'doesn't even shed tears or attempt to smile'.