Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A Texas congressman apologized Wednesday after he was literally caught with his pants down.

Rep. Joe Barton, a Republican who represents a district south of Dallas, made his mea culpa in a statement after a nude photo and a salacious sext surfaced on social media.

"While separated from my second wife, prior to the divorce, I had sexual relationships with other mature adult women," it read. "Each was consensual. Those relationships have ended."

Rep. Joe Barton, (R- Ennis) speaks at a news conference in Washington on June 14, 2017. Aaron Bernstein / Reuters file

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Barton closed by adding: "I am sorry I did not use better judgment during those days. I am sorry that I let my constituents down."

The close-up photo of Barton's genitals first appeared on an anonymous Twitter account and hit the web about a month after the veteran lawmaker announced his intention to run for re-election.

Asked whether Barton planned to step down, a spokeswoman, Sarah Dodd, told NBC News: "He is not resigning."

Barton, 68, is the latest politician whose past sexual indiscretions have come back to haunt him. A father of four and grandfather of five, he is the longest-serving member of Congress from Texas. And he is also no stranger to controversy.

In March, Barton was hit with sharp criticism after he lost his cool and told a constituent at a town hall meeting to "shut up" during a tense exchange over his decision to vote against a bill that aimed to stop violence against women.

In 2010, Barton was blasted by both Republicans and Democrats after calling BP, the energy company responsible for the Deepwater Horizon oil spill, the victim of a "$20 billion shakedown" by the Obama administration during a House Energy Committee hearing.

"I apologize," Barton, a former oil company executive, told BP chief Tony Hayward. "I'm ashamed of what happened in the White House yesterday."

Barton was referring to $20 billion in compensation that BP agreed to pay the victims of one of the nation's worst environmental disasters. He retracted his apology before the hearing was over.

CORRECTION (11:15 p.m. ET): An earlier version of this article misidentified the congressman who apologized. He is Joe Barton, not John Barton.