No one could fail to be moved by the pictures of Danny Nightingale reunited with his family yesterday. Most happy of all, I suspect, were the tabloid newspapers who lapped up the story with relish and conveniently found a reason to relegate the Leveson report to the inside pages.

The Court of Appeal’s decision appears right. Nightingale, an SAS sniper and veteran of Iraq and Afghanistan, had stored a pistol and ammunition given to him as a gift in his home and appears to have forgotten all about them. This folly, exacerbated by brain damage and trauma of losing colleagues killed in action, meant his crime was of no more than absent-minded negligence. A suspended sentence, leaving him free to go, is the correct decision, although an appeal against conviction is expected.

What concerns me is not the outcome of the case but the means of getting there.

This was a criminal matter played out in the tabloids, fuelled by petitions and riding on a wave of hysteria.

The media decided from the outset that this was a cause celebre. Nightingale, the decorated hero who’d given years of his life to public service, simply could not be guilty.

My Facebook feed was littered with calls to sign petitions for his release, with 107,000 people, fed by the tabloids, happy to add their support (many, I suspect, having not read the details of the case).

Even senior politicians jumped on the bandwagon. Defence secretary Philip Hammond acted completely beyond his remit in asking the attorney general, Dominic Grieve, to push for a review of the case.

When Grieve refused, citing that it would be ‘inappropriate’ to intervene, he was lambasted and rumours of a plot to have him removed gathered pace. Even the prime minister, who surely could not be expected to undermine the court system, was described as ‘refusing to back’ Nightingale – a move that ‘infuriated’ MPs.

This was a witch hunt in reverse – a media campaign based on the assumption that the court was wrong. It would be interesting to see whether a teenager from Hackney who stored a gun and mounted the same defence would be given equal support from newspaper editors.

It sets a dangerous precedent. Will we in future consider granting appeals based on the size of a petition, or the (understandable) sadness of the convicted man’s family? Will Daily Mail editorials hold more sway than court judgments?

Does the prime minister have to intervene when the convicted person is a national treasure? Do we really want to run a justice system as a popularity contest? Surely if recent months have taught us anything it is that fame, status or service to the country should be irrelevant in the eyes of the law.

In this case, justice has been done and Nightingale is a free man. I’m delighted that is the case.

But trial by tabloid is a worrying development – justice must be reached through the proper channels, not demanded by newspapers and politicians sensing a chance to latch onto a fashionable campaign.

Follow John on Twitter