Roseanne Barr has said she had taken sleeping pills before comparing a former White House aide to an ape on Twitter, and said she is tired of being “attacked and belittled”.

The TV star apologised for the offensive tweet about Valerie Jarrett, which prompted US network ABC to cancel Barr’s show Roseanne and networks airing reruns to pull them from the schedules.

Barr served as a star and executive producer on the ABC show, which was a ratings phenomenon when it returned to US television earlier this year for a 10th series, after its original run came to an end in May 1997.

The 65-year-old actress and her co-star John Goodman reportedly earned about 250,000 dollars (£190,000) per episode, according to Variety.

She earned about 21 million dollars (£16 million) for acting, directing and producing the nine episodes of the new series, Slate reported.

The return was watched by an estimated 18.4 million viewers in the US and Donald Trump phoned Barr to congratulate her on the success.

Barr has apologised to her colleagues who lost their jobs after she sent a now-deleted tweet referring to former Barack Obama adviser Ms Jarrett as a product of the Muslim Brotherhood and the Planet Of The Apes.

Responding to a fan on Twitter, she said she believed the show was axed because of a threatened boycott of the show’s advertisers.

She also addressed fans, writing: “hey guys, don’t defend me, it’s sweet of you 2 try, but…losing my show is 0 compared 2 being labelled a racist over one tweet-that I regret even more.”

She added: “Guys I did something unforgiveable so do not defend me. It was 2 in the morning and I was ambien tweeting-it was memorial day too-i went 2 far & do not want it defended-it was egregious Indefensible. I made a mistake I wish I hadn’t but…don’t defend it please. ty.”

She added: “Please don’t start all of that boycott abc stuff-I’m not a censor and they have the right to do what they wish. It’ all ok. thanks tho guys!

“I’m sorry 4 my tweet, AND I will also defend myself as well as talk to my followers. so, go away if u don’t like it. I will handle my sadness the way I want to. I’m tired of being attacked & belittled more than other comedians who have said worse.

“I think Joe Rogan is right about ambien. Not giving excuses for what I did(tweeted) but I’ve done weird stuff while on ambien-cracked eggs on the wall at 2am etc.”

Barr has previously apologised to Ms Jarrett, writing: “I want to apologize to you. I am very sorry to have hurt you. I hope you can accept this sincere apology!”

Apologising to colleagues on Roseanne who lost their jobs following the show’s cancellation, she wrote: “Don’t feel sorry for me, guys!!-I just want to apologize to the hundreds of people,and wonderful writers (all liberal) and talented actors who lost their jobs on my show due to my stupid tweet.”

Barr also revealed she would be appearing on US comedian Joe Rogan’s podcast on Friday.

As well as the apology, Barr retweeted messages of support from fans who had backed the star using the hashtag #StandWithRoseanne.

One tweet juxtaposed Barr’s comparison of Ms Jarrett with an ape to other posts comparing images of Mr Trump to orangutans.

Following her original comments, Barr was widely condemned by celebrities including her own castmates.

Sara Gilbert, who played her on-screen daughter Darlene, wrote: “Roseanne’s recent comments about Valerie Jarrett, and so much more, are abhorrent and do not reflect the beliefs of our cast and crew or anyone associated with our show. I am disappointed in her actions to say the least.”

“This is incredibly sad and difficult for all of us, as we’ve created a show that we believe in, are proud of, and that audiences love— one that is separate and apart from the opinions and words of one cast member.”

Producer and comedian Wanda Sykes had already quit the show before it was revealed it had been cancelled and another of Barr’s co-stars, Emma Kenney, revealed she was ready to leave in protest at the comments.

Film director Ava DuVernay praised ABC entertainment boss Channing Dungey, tweeting: “For the record, this is Channing Dungey. Sitting on top of your world like a Queen in full judgement of your garbage and taking it out. #Roseanne.”

Shonda Rhimes, the creator of ABC shows Scandal and Grey’s Anatomy, tweeted: “Thank you, Channing. #justice.”

She added: “The terrible part is all of the talented innocent people who worked on that show now suffer because of this. #notjustice.

“But honestly she got what she deserved. As I tell my 4 year old, one makes a choice with one’s actions. Roseanne made a choice. A racist one. ABC made a choice. A human one.”

Ms Jarrett is yet to respond to Barr’s apology on Twitter, only tweeting a response to actress Julia Louis-Dreyfus, who had shared a selfie of the two of them.

Earlier, speaking on MSNBC, she said: “I’m fine. I’m worried about the people out there who don’t have a circle of friends and followers who come right to their defence.”