Image copyright Getty Images Image caption Roberts' contribution to Doctor Who: The Target Storybook, has been removed

Writer Gareth Roberts has been dropped from an upcoming Doctor Who anthology over "offensive" transphobic tweets, BBC Books has confirmed.

Roberts, announcing his dismissal via Medium, said the publisher had "immediately folded" to pressure from the show's fandom and co-authors.

Parent company Ebury confirmed that Roberts' contribution to Doctor Who: The Target Storybook, will not feature.

The author said the tweets, from 2017, were made in "cheerful vulgarity".

The writer said that, as a gay man, he has "rejected restrictive cultural gender stereotypes for "as long as I can remember", but does not believe in gender identity.

"It is impossible for a person to change their biological sex. I don't believe anybody is born in the wrong body," he said.

Roberts has previously written for the TV series, including episodes for David Tennant, Matt Smith and Peter Capaldi.

Analysis: BBC LGBT correspondent Ben Hunte

Gareth Roberts' tweets have stunned the transgender community and their allies.

One of his more concerning posts refers to Paris Lees, Munroe Bergdorf, and Chelsea Manning, three of the world's most celebrated names in transgender rights, as "trannies". The word is now considered extremely derogatory.

An LGBT activist told me that on initially reading about Gareth's dismissal they felt sorry for him, until they then dug through his previous tweets.

Ebury's decision to drop Roberts over his tweets, which it says conflicts with its "values as a publisher", has sparked debate on social media.

Toby Young, author and associate editor of The Spectator, criticised the "shocking" decision, calling it an "affront to free speech" by a "publicly-owned company".

Skip Twitter post by @toadmeister This is shocking. It’s one thing for a commercial publisher to muzzle an author for their dissenting views on transgenderism. But for BBC Books to do it — a publicly-owned company — is an affront to free speech. Why should everyone pay the license fee if some views are censored? https://t.co/AscO0XEApw — Toby Young (@toadmeister) June 4, 2019 Report

BBC Books is, however, not publicly owned. It is a subsidiary of Penguin Random House, which is a majority shareholder.

Susie Day, one of the co-authors of the anthology, protested about Roberts' inclusion, saying that "being involved felt like a tacit endorsement of his views".

"I raised my concerns, and said if he was in, I was out," she wrote. "BBC Books made their decision. I'm grateful they took the opportunity to demonstrate that transphobic views have no place in the Whoniverse, both in and outside the stories."

Bethany Black, the first trans actor in Doctor Who, also praised the decision.

Skip Twitter post by @BeffernieBlack Gareth Roberts lost his spot in a Doctor Who anthology because of transphobic comments he made. Good.



Also good: I blocked @pinknews last time Roberts was at it, as being the first openly trans actor in Doctor Who, they DMd me everything he said to get a reaction from me. — Bethany Black (@BeffernieBlack) June 4, 2019 Report

Doctor Who, the long-running BBC series about an inter-galactic Timelord, will return with Jodie Whittaker continuing as its female lead in 2020.

Follow us on Facebook, on Twitter @BBCNewsEnts, or on Instagram at bbcnewsents. If you have a story suggestion email entertainment.news@bbc.co.uk.