Roseanne Barr went on an extended apology offensive Tuesday night after ABC canceled her hit sitcom "Roseanne" over a tweet in which Barr referred to a former adviser to President Barack Obama as an "ape."

Barr said she had been under the influence of the prescription sleeping pill Ambien on Monday night when she referred to the adviser, Valerie Jarrett, as a "child" of the "Muslim Brotherhood" and "Planet of the Apes."

"Roseanne's Twitter statement is abhorrent, repugnant and inconsistent with our values, and we have decided to cancel her show," read a statement Tuesday from ABC Entertainment President Channing Dungey.

Barr later apologized several times on her Twitter account.

The actress was responding to an online claim that Obama had spied on French presidential candidates and an accusation from a social media user that Jarrett, who was a senior adviser and assistant to the president for intergovernmental affairs in the Obama administration, had helped Obama "hide a lot."

President Barack Obama and Valerie Jarrett, a top adviser, in July 2014. White House Pool via Getty Images

"Muslim brotherhood & planet of the apes had a baby=vj" Barr said in a tweet that has been deleted. Jarrett was born in Iran to American parents — her father, a pathologist, directed an American hospital for children — and the family returned to the United States when she was 7 years old.

"I apologize to Valerie Jarrett and to all Americans," Barr said. "I am truly sorry for making a bad joke about her politics and her looks. I should have known better. Forgive me — my joke was in bad taste."

Barr said late Tuesday that she had been "ambien tweeting" and that she "went too far." Ambien and similar sleeping aids are formulated on zolpidem, which the Food and Drug Administration classifies as a hypnotic and which has been widely reported to lead some users to undertake uncharacteristic actions without any memory of what they were doing.

She urged her fans not to "feel sorry for me" and apologized specifically 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."