Media playback is unsupported on your device Media caption Keir Starmer: "We've got to have a way of balancing the right of the individual not to be subjected to threats and harassment"

New guidelines could see fewer people being charged in England and Wales for offensive messages on social networks.

The Director of Public Prosecutions said people should face a trial only if their comments on Twitter, Facebook or elsewhere go beyond being offensive.

He said the guidance combats threats and internet trolls without having a "chilling effect" on free speech.

The guidance means some people could avoid trial if they are sorry for criminal comments posted while drunk.

The guidance comes after a string of controversial cases, including the prosecution of a man who tweeted a joke threatening to blow up an airport.

Case law

Director of Public Prosecutions Keir Starmer said the Crown Prosecution Service (CPS) had now dealt with more than 50 cases relating to potentially criminal comments posted online - but there was so far very little case law set by senior judges to guide which trials should go ahead.

These interim guidelines are intended to strike the right balance between freedom of expression and the need to uphold the criminal law Keir Starmer , Director of Public Prosecutions Online comment crimes: Key cases

He said the interim guidelines, which come into force immediately, clarified which kinds of cases should be prosecuted and which would go ahead only after a rigorous assessment whether it was in the public interest to prosecute.

"The scale of the problem that we are trying to confront should not be underestimated. There are millions of messages sent by social media every day and if only a small percentage of those millions are deemed to be offensive then there is the potential for very many cases coming before our courts," Mr Starmer told BBC Radio 4's Today programme.

The guidance says that if someone posts a message online that clearly amounts to a credible threat of violence, specifically targets an individual or individuals, or breaches a court order designed to protect someone, then the person behind the message should face prosecution.

People who receive malicious messages and pass them on, such as by retweeting, could also fall foul of the law.

However, online posts that are merely "grossly offensive, indecent, obscene or false" would face a much tougher test before the individual could be charged under laws designed to prevent malicious communications.

Media playback is unsupported on your device Media caption Social media victim: I'm in favour of new guidelines

Mr Starmer said that many suspects in this last category would be unlikely to be prosecuted because it would not be in the public interest to take them to court.

This could include posts made by drunk people who, on sobering up, take swift action to delete the communication because they are genuinely sorry for the offence or harm they caused.

Individuals who post messages as part of a separate crime, such as a plan to import drugs, would face prosecution for that offence, as is currently the case.

A CASE TO PROSECUTE: Communications that are credible threats of violence

Harassment or stalking, such as aggressive internet trolling

Posts that breach court orders, such as those protecting the identity of a victim of a sexual offence

Mr Starmer said: "These interim guidelines are intended to strike the right balance between freedom of expression and the need to uphold the criminal law.

"The interim guidelines thus protect the individual from threats or targeted harassment while protecting the expression of unpopular or unfashionable opinion about serious or trivial matters, or banter or humour, even if distasteful to some and painful to those subjected to it."

Javed Khan, head of Victim Support, welcomed the new rules. He said: "Victims tell us that sustained and vindictive targeting on social media can leave long lasting emotional and psychological scars, so we warmly welcome clarification on how prosecutors will deal with online threats or harassment. The distinction between communications which constitute a credible threat and those which may merely cause offence is sorely needed."

Earlier this year, senior judges overturned the conviction of Paul Chambers who tweeted in 2010 that he would blow up Doncaster Airport because he was frustrated that it had been closed by snow.

'Judgement wrong'

Mr Chambers, and his many high-profile supporters, always said the tweet was meant as a joke and should not have been taken seriously.

Quashing the conviction, the Lord Chief Justice said Mr Chambers should not have been convicted of sending a menacing communication because it did not amount to a serious threat that created fear or apprehension.

Asked if he now regretted the prosecution of Mr Chambers, the DPP said: "A judgement call had to be made about that case. The Divisional Court ruled that our judgement call was wrong and I accept that."

Although the interim guidance is now in force, its final form is subject to a consultation that runs until 13 March 2013.