ATLANTA (AP) — A Georgia lawmaker will resign after exposing himself and yelling racial slurs on provocateur Sacha Baron Cohen’s cable TV show, a spokesman for House Speaker David Ralston said.

Rep. Jason Spencer had vowed to serve out his term despite the fallout. Now he’ll step down at month’s end, spokesman Kaleb McMichen told the Atlanta Journal-Constitution late Tuesday.

In Sunday night’s broadcast of Cohen’s Showtime series “Who Is America?” Cohen poses as an Israeli military expert who persuades Spencer to take part in several outlandish exercises. The lawmaker is told they’re making a counterterrorism video.

Spencer repeatedly shouts a racial slur for black people after Cohen tells him the tactic is useful for drawing bystanders’ attention to an unfolding attack.

He also drops his pants, then his underwear, before backing his exposed rear end toward Cohen while shouting “USA!” and “America!” Cohen told Spencer this would incite fear in homophobic jihadists. The segment also shows Spencer speaking with a mock Asian accent while using a selfie-stick to surreptitiously insert a camera phone between the legs of a woman dressed in traditional Muslim clothing.

Ralston and others had called for his immediate resignation.

In a statement Monday, Spencer apologized for the “ridiculously ugly episode,” but he initially refused to step down.

Spencer lost the Republican primary in May, but he could have remained in public office through the November election.