The "#Represent" campaign was created to encourage people to leave messages of support for the British Athletics team, which in turn generates pictures of athletes holding boards showing the name the person submitted.
However, several users saw it as an opportunity to post offensive messages, including about Madeleine McCann and Jimmy Saville (below), which were then put onto the pre-shot images of top athletes.
These messages have since been removed.
The National Lottery was forced to apologise via Twitter, saying in two tweets published early this morning: "We are aware that some people are maliciously targeting our British Athletics Twitter campaign with offensive and abhorrent content.
"We are dealing with this as quickly as possible and are hugely sorry for any offence caused by this malicious act."
The flop campaign echoes another earlier this summer by Walkers Crisps which was hijacked in a similar way.
Matt Donegan, the managing director of Social Circle, told Campaign that marketers need to prepare for online trolls in advance of any user-generated content campaign by having processes in place to prevent subversive messages being posted.
He explained: "Whether this is a verification process, or a human checking posts before they are created, the sad reality is that brands need to assume that there will be people trying to hijack any campaign. Preparation, personality and interaction are key when managing an influencer campaign, as well as using the expertise of those familiar with the social media platform to look in advance for any weak points."
A version of this article was first published by PRWeek.