Image copyright @TNLUK

When it comes to internet campaigns, big brands should never underestimate the power of social media in both their success and downfall.

This time it's the National Lottery whose idea for a Twitter campaign around the World Athletics Championship has spectacularly backfired, leading the organisation to remove tweets when audience responses generated offensive imagery.

Twitter users were asked to retweet a post from @TNLUK with the hashtag #Represent. Those doing so would receive a thank you tweet, including their Twitter account name being held up on a sign by one of the stars of the British Athletics team.

But the campaign was hijacked when users changed their Twitter handles to controversial names and statements.

Image copyright @TNLUK

The replies were being generated automatically, so the responses - some of which referred to Jimmy Savile and Madeleine McCann - were not examined before being posted. Much of the content is too offensive to display in this article.

They continued to be posted by the National Lottery's account throughout Monday night.

As one Twitter user noted: "@TNLUK are learning a valuable lesson about auto-replies and the need to filter them."

Image copyright @TNLUK

'Hugely sorry'

As more and more responses were generated, Twitter users asked the National Lottery to take action, which it did early on Tuesday morning.

In two separate tweets the organisation posted: "We are aware that some people are maliciously targeting our British Athletics Twitter campaign with offensive and abhorrent content. (1/2)

"We are dealing with this as quickly as possible and are hugely sorry for any offence caused by this malicious act. (2/2)"

A Camelot spokesperson also told the BBC: "We have disabled the campaign, deleted the inappropriate tweets from our feed and are continuing to look into exactly what happened. We are hugely sorry for any offence caused to our players, the athletes concerned and British Athletics by this deliberate act."

The tweets were also removed but many people on Twitter had saved screenshots of the messages, which they tweeted in response to the National Lottery's apology.

Some Twitter users blamed the National Lottery for the posts, rather than the those responding on the social media.

"How can you not have known something like this would get hijacked? That's quite some ignorance of the platform!" posted one Tweeter.

Others voiced their disgust at responses about cancer victim Bradley Lowery and Hillsborough."Sick and vile," wrote one Twitter user.

A similar PR gaffe occurred when the "Walkers Wave" campaign asked social media users to respond to a tweet from the official Walkers Crisps Twitter account with a selfie, using the hashtag #WalkersWave, as part of the chance to win Champions League tickets.

Image copyright @Walkers_Crisps Image caption Walkers crisps launched a Twitter campaign which led to Gary Lineker holding up pictures of criminals such as Harold Shipman and Fred West

The user's picture was incorporated into a personalised video, featuring Gary Lineker, automatically tweeted and captioned by Walkers. But social media users responded with pictures of serial killers and disgraced celebrities.

As another Twitter user asked the National Lottery: "Did you learn nothing from the Gary Lineker / Walkers Crisp fiasco a few weeks ago?"

By Rozina Sini, BBC's UGC and Social News Team