Twitter has apologised for allowing adverts to be micro-targeted at certain users such as neo-Nazis, homophobes and other hate groups.
The BBC discovered the issue and that prompted the tech firm to act.
Our investigation found it possible to target users who had shown an interest in keywords including "transphobic", "white supremacists" and "anti-gay".
Twitter allows ads to be directed at users who have posted about or searched for specific topics.
But the firm has now said it is sorry for failing to exclude discriminatory terms.
Anti-hate charities had raised concerns that the US tech company's advertising platform could have been used to spread intolerance.
What exactly was the problem?
Like many social media companies, Twitter creates detailed profiles of its users by collecting data on the things they post, like, watch and share.
Advertisers can take advantage of this by using its tools to select their campaign audience from a list of characteristics, for example "parents of teenagers", or "amateur photographers".
Twitter's ads tool had allowed sensitive keywords to be targeted
They can also control who sees their message by using keywords.
Twitter gives the advertiser an estimate for how many users are likely to qualify as a result.
For example, a car website wanting to reach people using the term "petrolhead" would be told that the potential audience is between 140,000 and 172,000 people.
Twitter's keywords were supposed to be restricted.
But our tests showed that it was possible to advertise to people using the term "neo-Nazi".
The ad tool had indicated that in the UK, this would target a potential audience of 67,000 to 81,000 people.
Other more offensive terms were also an option.
How did the BBC test this?
We created a generic advert from an anonymous Twitter account, saying "Happy New Year".
We then targeted three different audiences based on sensitive keywords.
Twitter's website said that ads on its platform would be reviewed prior to being launched, and the BBC's ad initially went into a "pending" state.
But soon afterwards, it was approved and ran for a few hours until we stopped it.
In that time, 37 users saw the post and two of them clicked on a link attached, which directed them to a news article about memes. Running the ad cost £3.84.
, but acknowledged they had not been applied correctly.
"[Our] preventative measures include banning certain sensitive or discriminatory terms, which we update on a continuous basis," it said in a statement.
"In this instance, some of these terms were permitted for targeting purposes. This was an error.
"We're very sorry this happened and as soon as we were made aware of the issue, we rectified it.
"We continue to enforce our ads policies, including restricting the promotion of content in a wide range of areas, including inappropriate content targeting minors."