The history of American politics abounds with examples of leaders sunk by scandal, the dark details excavated by their enemies.

Lee J. Carter, a Virginia state lawmaker with enough proverbial skeletons to crowd a graveyard, has taken it upon himself to beat any potential rival to the punch.

In a whiplash-inducing confessional on Twitter, Carter, a Democratic delegate from Prince William County, recently told his 18,000 followers he needed to share details of his past before unidentified foes “try personal smears.”

Once, a few years back, he was fired from a job, he tweeted. At 18, while in the Marines, he was arrested for suspicion of assault, a charge he said was dismissed. A “terrible student” in high school, he said “horrible things” on the Internet — things that were “homophobic, trans-phobic, sometimes sexist or racially insensitive.”

The delegate’s compendium of lowlights included layoffs, a foreclosure and a car repossession and a time when the Confederate flag made him feel something more positive than the revulsion he currently experiences.

“I’m on divorce #3,” Carter, 31, continued, before describing himself as the victim of “abuse, including rape.”

“And just like everyone else under 35,” he tweeted, “I’m sure explicit images or video of me exists out there somewhere.”

He then took pains to reassure his audience he is no Anthony Weiner, the former congressman whose in flagrante selfies caused a national furor. “I never sent them unsolicited,” Carter wrote. “And never while I was in a relationship.”

As the General Assembly’s only self-proclaimed socialist, Carter quickly distinguished himself in Richmond after his 2017 upset victory over Del. Jackson Miller, the GOP’s third-highest-ranking House member. While Carter spoke during a hearing earlier this year, a Democratic colleague seated behind him teasingly held up a photo of a Soviet hammer-and-sickle.

But Carter’s revelations about his personal life in early September — delivered in a spasm of tweets on a Friday night as he sat alone on his couch — brought him new notoriety and caused a veritable ripple of gasps within Virginia’s political class, including Democrats desperate to overtake the Republicans’ 50-to-49 majority in the House.

Among his Twitter followers, the immediate response was largely positive — “Amazing honesty,” wrote one, “It’s genius,” wrote another. But others were plainly flummoxed. “Bruh you don’t have to get married everytime,” wrote a third.

Up for reelection in 2019, Carter’s self-induced “Jerry Springer” splash is making party loyalists fret that he may have etched a bull’s eye on his own back.

“This is just not a message that will play well with Grandma,” said Ben Tribbett, a Democratic consultant based in Northern Virginia. “It wasn’t just the content of the tweets, it was the volume, which painted a picture of someone whose life is not in order. And that’s never a good look for an elected official.”

Carter, in an interview at a Manassas coffee house, insisted his life is just fine, particularly since May, when he separated from his third wife, from whom he is in the process of divorcing. But he said by revealing the less-than-flattering details, he hopes to neutralize what he expects will be a Republican effort to tarnish him.

During his first campaign, a conservative blog posted several pages from a court document relating to a child support dispute he had with his second wife, the mother of their 7-year-old daughter. More recently, he said he became alarmed when rivals tried to “smear” Julie Salazar, a member of the Democratic Socialists of America, as she campaigned for a New York state Senate seat.

“I said, all right, I need to just put all of this out there so people can see what people will try to smear me with,” Carter said, his boyish face topped by a thatch of red hair. “Let people know about it now on my terms so they can see that I’m a normal person with a messy life like everyone else.”

Bill Card, chair of Prince William’s Republican Party, said he is uninterested in delving into Carter’s past and would encourage any Republican challenger to avoid the subject altogether.

“Lee Carter’s weakness is his political philosophy,” Card said. “This country has been against socialism since 1917. How anyone could come up with the idea that that is an acceptable direction is absolutely appalling.”

Instead of exploiting Carter’s personal problems, Card said, “I’d be delighted to buy him a Bible. I think he’d be better off establishing a relationship with Jesus Christ.”

Carter, as it happens, was raised “irreligious” and regards himself as “largely agnostic,” something he felt compelled to reveal in the fifth of his 15 tweet confessional.

Transparency or political hara-kiri?

It was another Carter — Jimmy of presidential fame — who astonished Americans with a TMI (too much information) moment in 1976, telling Playboy magazine he had looked at “a lot of women with lust. I’ve committed adultery in my heart many times.”

A generation later, then-New York City Mayor Rudolph W. Giuliani volunteered during a news conference that his marriage was breaking up. By then, the mayor had been seen around town with a new paramour.

In 2009, then-Gov. Mark Sanford of South Carolina announced he was in the midst of a heart-skipping extramarital affair, a revelation that did not stop him from completing his term and then getting elected to Congress.

Mostly, though, politicians’ secrets are unearthed by rival operatives and reporters. Campaign strategists largely regard unprompted confessionals as a pointless form of political hara-kiri.

“First off, it’s no one’s business,” said Dave “Mudcat” Saunders, a Democratic strategist and onetime adviser to former senator John Edwards, whose political career ended in a scandal that involved a mistress, a newborn and illegal campaign payments.

“I believe politics is all about offense,” Saunders said. “When you’re on offense you’re driving votes. When you’re on defense, you’re trying to keep the votes you got. Is anyone going to see that [expletive] and vote for you? It’s defense while you’re still carrying the ball.”

Referring to Lee Carter, Chris LaCivita, a Republican strategist and a seen-it-all veteran of numerous campaigns in Virginia and beyond, said he had never known a candidate to “lay out to this degree of specificity — or even in general — their vulnerabilities.”

“It sounds like Mr. Carter doesn’t want to be in the State House anymore,” said LaCivita, bursting into laughter.

Yet LaCivita predicted that, before he meets a Republican in a general election, Carter’s public unburdening would probably prompt a Democrat to take him on.

“Don’t think the Democratic leadership didn’t look at these tweets and say, ‘What’s wrong with this guy?’ ” LaCivita said. “At the end of the day, Democrats should say, ‘My God, if only half of this is true, then we won’t be able to hold the seat.’ ”

Carter grew up in North Carolina, spent five years in the Marines and became an electronics repairman, the job he held when he suffered an electrical shock and hurt his back in 2015. It was his inability to collect workers’ compensation that inspired him to run for office.

And it was Sen. Bernie Sanders (I-Vt.), then running for president, who inspired Carter to Google, “What is socialism?” — a question that led him to embrace the political and economic philosophy as his own.

In a 2017 mailer, incumbent Jackson Miller’s campaign Photoshopped Carter’s smiling face alongside the visages of Karl Marx, Friedrich Engels, Vladi­mir Lenin, Joseph Stalin and Mao Zedong.

“SOCIALISM” was printed across the top.

Miller said he was aware of his challenger’s marital problems but did not raise them because “those were personal issues, and I didn’t want to drag him or his family through the mud.”

“Now everyone knows,” Miller said.

Soon after he posted his tweets, Carter said he received a call from House Democratic leader David J. Toscano (D-Charlottsville) who expressed worry that “this might hurt you.”

“It was concern and confusion,” Carter said, adding “older” colleagues tended to be “really perplexed” while younger allies “agreed that it was a smart thing to get it out there and to let yourself be vulnerable to the public.”

Del. Charniele L. Herring (D-Alexandria), who chairs the Democratic House caucus, described Carter’s relationship with the group as “good” and praised him for being “true to his values and being transparent.”

“That’s Lee,” she said. “He’s an interesting person.”

Others declined to offer an assessment, such as State Sen. Jeremy S. McPike (D-Prince William), whose district includes Carter’s seat.

“Frankly, I haven’t tracked a lot of Lee’s stuff,” McPike said.

Reached on her cellphone, Del. Danica Roem (D-Prince William), who was elected at the same time as Carter, said of his tweets: “It’s very much not my concern. I’m not going to weigh in on it, period.”

While contemplating whether to divulge details about his life, Carter said he was inspired by Roem, who once told an interviewer she had used alcohol to “perpetuate self-destructive behavior.”

“A lot of problems we have are the result of people trying to hide who they are so they can get reelected,” Carter said. “If you have real people — normal people, working-class people — you’re going to have to get past that fear that you can’t perfectly manicure your image. Just be a normal person. It shouldn’t be a big deal saying that.”

For all his conviction, Carter said he was “terrified” on the night of Sept. 7, as he sat alone in his apartment at 10:42 p.m., and tweeted, “So here are some of the things you can expect to be used against me.”

He fell asleep as his words were retweeted and retweeted some more. The next morning, he awoke to more of the same.