People who post offensive messages on websites such as Twitter while drunk only to delete them when they sober up are unlikely to face criminal prosecution, the director of public prosecutions said yesterday.

In guidelines which come into force today, Keir Starmer said he was concerned that prosecuting people for writing "offensive, shocking or disturbing" messages would have a "chilling effect" on free speech.

He urged social media websites such as Facebook and Twitter to support the guidelines and encouraged them to take "swift and effective" action to remove offensive posts from the internet.

He added, however, that prosecutors should still take "robust" action if people threatened violence, harassed individuals or breached court orders.

Internet "trolls" who carry out sustained attacks on individuals or make "grossly offensive or threatening remarks" will be taken to court.

The guidance was issued amid growing concerns that criminal prosecutions are being brought against people on the internet under outdated legislation drawn up before Twitter and Facebook even existed.

Mr Starmer said that while 18 months ago there were no criminal prosecutions for offensive internet comments, there have now been between 50 and 60 and in future there could be thousands.

Mr Starmer said: "In most cases once you put the safeguards in place then a prosecution is unlikely to be the appropriate response. It makes it less likely that these cases will be prosecuted.

"Prosecution should be proportionate. In a number of cases that we've seen it's clear that either once challenged or once sober the individual takes down offensive material very quickly and expresses genuine remorse.

"I hope through our positive dialogue with Facebook and Twitter that they might be able to support the guidelines and that therefore they might think it appropriate to take swift action."

Under the new guidelines, prosecutors must demonstrate that messages on the internet are "grossly offensive", that prosecution in the public interest and that they have caused the victim "distress or anxiety".

Prosecution is likely to be unnecessary if the offending message is removed, by either the individual or service provider, and if it was not intended for a wider audience.

In July the country's most senior judge overturned a man's conviction for joking about blowing up an airport on Twitter. The Lord Chief Justice, Lord Judge, said the message posted online by Paul Chambers could not be considered "menacing".