Barton, never at a loss for words, made his views on the Terry case very plain in a series of robust tweets on Friday evening. It was clear he thought Terry's would be a jury trial. The fact that it will be held at a magistrates court, whose justices and district judges are regarded as harder to sway than a jury, might save Barton an appearance in the dock himself. The attorney general, Dominic Grieve, by not taking action in this instance, seems to have taken the view that his tweets have not caused a serious impediment to John Terry's case by influencing a witness.

However, this latest example of the use of social media potentially leading to a contempt of court should sound alarm bells at the Ministry of Justice, because the attorney general faces a potentially serious challenge to the ability of the courts to give people a fair trial. It is only a matter of time before someone with as many followers as Barton - almost 1.2m, at the last count - and as loose a grasp of the law causes the collapse of a crown court trial.

The law on contempt, as enacted in 1981, places the burden on the publisher not to cause a substantial risk of serious prejudice to active proceedings – "active" being as soon as someone is arrested, or a warrant is issued for their arrest. Back then publishers were invariably established media – newspapers and broadcasters. They know how to avoid contempt, and they pay the often very heavy price when they stray across the line. The Sun, Mirror, and Daily Mail have all faced actions over the past year after having published prejudicial material, in print or online. But as Barton's tweets (now deleted) showed, he had no knowledge of contempt law. Ignorance of the law is no excuse, and the fact contempt is a strict liability offence also removes Barton's intent from the equation in any potential prosecution too.

Being pragmatic, though, does Dominic Grieve really want to allow a situation to continue where the tweets of a celebrity or sports star with a million-plus followers bring a high-profile trial to a halt, at great cost to the taxpayer? Prejudicial conversations about ongoing trials which were once confined to the dinner table, pub or dressing room are now conducted with an online audience of millions.

In portraying himself as a martyr for free speech, Barton unfortunately fails to recognise the competing right to a fair trial and the presumption of innocence that is central to that right. The Law Commission is looking at how to deal with contempt by publication on the internet, but work does not start on that until 2014, with a report due in winter 2016. By that time Twitter may be dead and buried and new forms of social media throwing down newer challenges to the judicial system.

What is needed now is a more proactive approach than simply bringing prosecutions, as Grieve has shown himself willing to do. That concentrates the minds of newspaper editors, but it will not prevent the sort of contempt that Barton flirted with on Friday evening. The Ministry of Justice cannot police Twitter and other social media, but what it can do is make the public more aware of the right to a fair trial and how that can be put in jeopardy. A campaign of public information, waged on the very social media that can prejudice a trial, might go some way to preventing public figures with large followings damaging a defendant's right to a fair trial.

This article was updated to reflect the attorney general's decision not to take action at 16.58 on 6 February 2012