Fanatical. Deluded. Emotive nonsense. These are unusually strong terms for a judge to use, particularly in a case as intensely sad and bitterly contested as that of the terminally ill child Alfie Evans. Yet Mr Justice Hayden, referring to some of the campaigners now surrounding Alfie’s parents, did not mince his words, after this most hellish of ethical dilemmas ended this week in a court ruling that the child’s ventilator be switched off against the family’s wishes.

The judge was careful not to attach blame to Tom Evans and Kate James, who cannot accept the settled view of their son’s doctors that his brain has been damaged catastrophically by an as yet undiagnosed condition, or that the intensive treatment required to keep him alive is no longer in his best interest and may be causing him suffering.

Alfie’s parents have fought like tigers both in and out of court and no parent – even those whose sympathies in this case are with the doctors facing death threats for doing what they honestly believe is the right thing – will begrudge the family their right to clutch in their grief at every straw there is.

But the high court judge is surely right to question the motives of some of those extending straws. The most disturbing aspect of this case is the sense that it is now being exploited by those who see Alfie not as a desperately sick little boy, but as an expedient means of advancing their own ideological cause.

That description doesn’t just apply to the pro-life movement, of course. Among Alfie’s viscerally engaged army of Facebook supporters, which includes many parents of small children, you will find anti-vaxxers using the story to peddle utterly deluded junk science theories about the Vitamin K injection every newborn gets. You’ll find American gun lobby enthusiasts ranting on about how this is what happens when “the government” runs people’s lives and that’s why everyone needs to keep hold of their weapons; never mind that this decision has nothing to do with the government, resting as it does on the independent judgment of doctors upheld by an independent judiciary.

Others have sought to use the case to score cheap, wildly inaccurate points over healthcare reform in the US; to claim this is where “socialised medicine” gets you, when without the NHS and its daily miracle of providing treatment free at the point of use, Alfie’s parents would now be struggling with medical bills running into the millions.

And where far-right conspiracy sites such as Infowars and Breitbart rush in, an army of trolls inevitably follows. Staff at Alder Hey children’s hospital have experienced a horrific barrage of death threats and other online abuse. There have been ugly scenes at the hospital too, reports of over-zealous protesters blocking ambulances or intimidating visitors and patients. It is all too uncomfortably reminiscent of those who harass pregnant women outside abortion clinics and threaten to kill doctors offering terminations, so high on their self-righteous mission to save that all other human lives cease to matter.

Alfie’s parents, Tom Evans and Kate James. Photograph: Philip Toscano/PA

But none of that is quite what the judge meant. His concern centres specifically on the way the Evans family has been taken under the wing of a hitherto little-known evangelical group called the Christian Legal Centre, which has supplied the parents with a barrister and, somewhat dubiously, the services of a law student named Pavel Stroilov. A statement drafted for Alfie’s father was, according to Hayden, loaded with “vituperation and bile” against the hospital, which had not helped the baby’s case. At one point, Stroilov apparently became party to an attempt by Alfie’s father to have the doctors prosecuted for murder.

The family’s former solicitor Mary Holmes has accused activists of seeking to “keep this child alive at any costs and not for the right reasons”, using the case to raise their profile with interventions such as securing Tom Evans an audience with the pope. Most seriously, Stroilov stands accused of giving Evans inaccurate advice in a letter stating that he had the legal right to remove his son from the hospital, despite a court order to the contrary, causing an understandably emotional standoff between the parents and the hospital when it became clear that was not the case. What is compassionate or Christian about giving a desperate man false hope?

The judge’s objection to an outpouring of what he called “emotive nonsense” in his courtroom is not to be confused with heartlessness. Rather, it is a recognition that courts are the one place where, in cases like these, reason can still prevail over white-hot emotion; that their job is to provide a calm enough environment for doctors facing impossibly difficult choices to explain their clinical reasoning, and for evidence to be considered on its merits. For in British law, what matters is what is in the best interest of the child, not of the parents or the doctors or wider public opinion, and certainly not of organised religion. The court process functions only when the adults involved can be mature enough to put their own interests to one side, which means lawyers in such cases acting as advocates for their clients – not campaigners advancing their own beliefs.

And while advocacy may mean fighting to the bitter end, there are times when it means gently introducing a client to the idea that it is time to stop; that however unreconciled they are to a painful verdict, it isn’t going to change. It is a conversation that would be familiar, ironically enough, not only to doctors but to priests.

The church’s role can be to give hope where secular medicine has none. Light a candle, say a prayer, and just for a minute you might believe in a miracle. Yet that is not its only role at the end of life, when the dying and the grieving are looking as much for comfort as for hope; and for help in accepting the inevitable with grace. As Psalm 23: 4 has it, “Yea, though I walk through the shadows of the valley of death, I will fear no evil; for thou art with me.” This family is walking through the shadows of that valley now, and they deserve to be accompanied by people with only their best interests at heart. May they find the comfort and grace they deserve.

• Gaby Hinsliff is a Guardian columnist