(CNN) Jason Spencer, a Georgia state lawmaker who dropped his trousers and repeatedly used the "n-word" on an episode of the Showtime series "Who Is America?" on Sunday night, has announced his resignation.

His resignation will take effect on July 31, according to a letter he submitted to Georgia House Speaker David Ralston.

Spencer, a Republican who represents the community of Woodbine in southeast Georgia, appeared in a segment in which the show's star, Sacha Baron Cohen, played a character named Col. Erran Morad.

Spencer was pranked into believing the comedian was an Israeli anti-terrorism expert who was able to convince the legislator that a series of racist acts would protect him against terrorists.

They first discussed Spencer's support of a burqa ban.

Spencer told Cohen's character, "I don't call it a burqa ban, I call it an anti-masking statute."

From there, Cohen engaged in a series of supposed anti-terrorism exercises that included telling Spencer to yell as a way of attracting attention during an ISIS kidnapping attempt.

"In America there is one forbidden word," Cohen said. "It is the 'n-word.'"

After Spencer yelled the racial slur, Cohen responded "Are you crazy? The 'n-word' is noonie! Not this word. This word is disgusting."

"Got it," Spencer said.

Cohen also got Spencer to imitate an Asian accent in an exercise that had him pretending to be an Asian tourist in an attempt to take a photo under a person's burqa and to drop his trousers "to use your buttocks to intimidate ISIS."

Ralston called Spencer's actions and language "reprehensible" in a statement provided to CNN, and called for him to resign, saying: "Georgia is better than this."

The actions and language used by Jason Spencer are appalling and offensive. There is no excuse for this type of behavior, ever, and I am saddened and disgusted by it. — Governor Nathan Deal (@GovernorDeal) July 23, 2018

Georgia Gov. Nathan Deal tweeted about Spencer's actions on Monday.

"The actions and language used by Jason Spencer are appalling and offensive," Deal tweeted. "There is no excuse for this type of behavior, ever, and I am saddened and disgusted by it."

JUST WATCHED Did Sacha Baron Cohen punk Dick Cheney? Replay More Videos ... MUST WATCH Did Sacha Baron Cohen punk Dick Cheney? 02:12

Spencer has not returned calls from CNN, but told the Atlanta Journal-Constitution the Showtime series got him to participate by taking advantage of his fears that he or his family would be attacked -- fears sparked by death threats he says he received after he proposed legislation barring Muslim women from wearing burqas in public.

"In posing as an Israeli agent, (Cohen) pretended to offer self-defense exercises. As uncomfortable as I was to participate, I agreed to, understanding that these 'techniques' were meant to help me and others fend off what I believed was an inevitable attack.

"My fears were so heightened at that time, I was not thinking clearly nor could I appreciate what I was agreeing to when I participated in his 'class.' I was told I would be filmed as a 'demonstration video' to teach others the same skills in Israel. Sacha and his crew further lied to me, stating that I would be able to review and have final approval over any footage used.

"I deeply regret the language I used at (Cohen's) request as well as my participation in the 'class' in general. If I had not been so distracted by my fears, I never would have agreed to participate in the first place.

"I apologize to my family, friends, and the people of my district for this ridiculously ugly episode," Spencer said.

Spencer told the Atlanta Journal-Constitution the show "exploited" his state of mind "for profit and notoriety."

"This media company's deceptive and fraudulent behavior is exactly why President Donald Trump was elected," he said in a statement last week in response to other politicians falling prey to the comedian.

Showtime had no comment when contacted by CNN on Monday.

Boker tov. I have been inform elected official & all-round mensch I meet, Jason Spencer, have somehow been portray in bad light by Showtime. To reveal the truth, here is the unedited film. Do not worry Jason Shpenker, Erran Morad have got your backsidehttps://t.co/Tnj7lX8zf5 — Colonel Erran Morad (@ErranMorad) July 23, 2018

Still in character, Cohen, as Israeli Col. Erran Morad, posted videos of Spencer on Twitter with this message:

"Boker tov. I have been inform elected official & all-round mensch I meet, Jason Spencer, have somehow been portray in bad light by Showtime. To reveal the truth, here is the unedited film. Do not worry Jason Shpenker, Erran Morad have got your backside."

Previous calls for Spencer's resignation

Some called for Spencer's resignation last year after he warned former state Rep. LaDawn Jones, a black woman, that she would not be "met with torches but something a lot more definitive" if she continued to call for the removal of Confederate statues in south Georgia, and suggested that someone who didn't understand this "will go missing in the Okefenokee" swamp.

Spencer was elected to the Georgia House in 2010. He has served four terms and is still in office, but was defeated by political newcomer Steven Sainz in the Republican primary in May.