Harry Potter author J.K. Rowling shut down a homophobic troll on Twitter who attempted to suggest that out diver Tom Daley's sexuality had something to do with his early exit from the Rio Olympics.

Daley and Daniel Goodfellow won a bronze medal in the synchronized 10m platform at the games. But the 22-year-old failed to qualify for the 10m platform final.

“Turning gay doesn't seem to have done Tom Daley any favours at #Rio2016,” the group Christian Voice tweeted.

“Can't decide which is more offensive in this tweet, the stupidity or the spite,” Rowling replied.

Daley tweeted that he was “truly heartbroken” by his loss at the Olympics, adding that he would “never give up on his dream of being an Olympic champion.”

Daley came out gay in 2013 and later became engaged to Dustin Lance Black, a Hollywood screenwriter. In a separate tweet, the Christian Voice blamed the 42-year-old Black for Daley's sexuality.

“#Rio2016 And we need to remember that Tom Daley only went gay because he was seduced by an older man,” the group messaged.