Congressman Joe Barton (R-TX) announced Thursday that he will retire amid a slowly unfolding scandal that began with a nude photo and expanded to include sexually explicit messages to a constituent.

Barton’s decision comes after a sexually explicit image of the lawmaker appeared online last week and a report that he had sent sexually suggestive messages to a Republican activist while still married to his second wife.

Barton, who represents the state’s sixth district in the Dallas metro area, apologized when the nude photo surfaced last week for “sexual relationships with other mature adult women” that took place prior to his divorce from his second wife. He described the relationships as consensual.

Then, Wednesday, the Fort Worth Star-Telegram reported that Barton had repeatedly sent “inappropriate” and sexualized messages to a Republican activist on Facebook, including asking if she was wearing “a tank top ... and no panties.”

Barton, in an interview with the Dallas Morning News, said Thursday he is leaving Congress in 2018 because he has “always listened to the people of Texas.”

“There are enough people who lost faith in me that it’s time to step aside and let there be a new voice for the 6th district in Washington, so I am not going to run for re-election,” Barton explained.

Barton added that he thought he could still win re-election, but didn’t want to put his family through a potentially “nasty campaign.”

Barton is retiring as politicians on Capitol Hill are facing new scrutiny for sexual harassment and misconduct. But unlike the case of fellow Rep. John Conyers (D-MI), who has been accused of harassment by former female staffers, Barton is embroiled in a more complicated scandal. The nude image was allegedly shared without his consent — meaning Barton could be a victim of “revenge porn,” and the Facebook messages as reported by the Star-Telegram show Barton repeatedly pushing conversations about politics into sexual territory:

At 11:40 p.m. June 18, 2012, Barton sent a message: “wanna tell me what u r wearing or not wearing tonight miss sweet dreams.” Canon responded that she was ‘still in my ‘regular’ clothes!’ ”

Now, in the wake of these scandals, Barton’s tenure in Congress is now coming to a close; he’s joined a growing list of Republican lawmakers not seeking re-election.

How a naked photo of Barton helped end his Congressional career

Barton’s troubles began after a Twitter user posted late last week— and later deleted — a photo of a man posing naked (or mostly naked) that resembled the 68-year-old Barton. It circulated online, and the Texas lawmaker later confirmed he was the man in the photo.

"While separated from my second wife, prior to the divorce, I had sexual relationships with other mature adult women," Barton told the Texas Tribune in a statement last Wednesday. "Each was consensual. Those relationships have ended. I am sorry I did not use better judgment during those days. I am sorry that I let my constituents down."

It’s still unclear who posted the photo online and how they obtained it. Not long after Barton issued his apology, the Washington Post reported a woman said she and Barton had exchanged sexual texts and met for sex during a five-year period, beginning in 2011. (Barton was married for some of this period, according to the woman.) She learned that Barton had also been communicating or having sexual encounters with other women and got in touch with them.

Then Barton confronted her. The woman provided a 2015 phone recording to the Washington Post in which Barton asked her to stop talking to the other women, implies she is blackmailing him a threat to release nude photos, and says he’s willing to go to the Capitol Police.

“I would tell them that I had a three-year undercover relationship with you over the Internet that was heavily sexual,” Barton said to the woman in the recording, according to the Post, “and that I had met you twice while married and had sex with you on two different occasions and that I exchanged inappropriate photographs and videos with you that I wouldn’t like to be seen made public, that you still apparently had all of those and were in position to use them in a way that would negatively affect my career. That’s the truth.”

The woman denied that she threatened to make the material public, and she also denied leaking the explicit image of Barton that appeared on the internet earlier that week.

Barton said he had asked the Capitol Police to open an investigation, but the status of that investigation is unclear. There is no federal law prohibiting “revenge porn” — essentially, the release of explicit images or pornography without the subject’s consent — though Texas did pass such a law in 2015.

On Tuesday, a bipartisan group of lawmakers put forward legislation that would make “revenge porn” a federal crime. Barton told the Dallas Morning News he would vote for it.

Barton also sent text messages to a Republican activist asking what she was wearing

The circumstances surrounding the release of Barton’s nude photo remain murky, but both Barton and the woman interviewed by the Washington Post seem to suggest it was taken in a consensual sexual relationship. Still, Republicans in Texas already suggested he shouldn’t run again.

Then the Star-Telegram published the messages between Canon and Barton, which are more ambiguous. The transcripts aren’t complete (some of Canon’s responses aren’t included, for example), but the excerpts published show the representative repeatedly trying to sexualize the conversation while she tries to change the subject.

The messages were from 2012 and 2013, when Barton was still married.

Canon told the Fort Worth Star-Telegram that the congressman “took it a step too far on rare occasions.” (Barton confirmed that he exchanged messages with Canon, but did not elaborate on the content.)

“Tell me what else u r wearing... if anything,” Barton wrote in one of the messages published by the Star-Telegram.

Canon responded: “‘Anything.’”

“So..that means u r wearing a tank top only..and no panties?” Barton answered, adding: “Right now?”

“OK thats enough. You know my attire! Good night....” Canon wrote.

“Answer me miss evasive,” Barton wrote back. “And then u can aske me. If u wish.”

Canon, who remains active in Republican politics in Arlington, Texas, said she did not think Barton’s behavior was appropriate, and also implied that she wanted to see Barton step aside. “He actually thinks he can win,” Canon said of Barton’s now-ended re-election bid. “I thought maybe if I come forward, maybe others will come forward too.”