Anthony Weiner was sentenced to 21 months in prison Monday on federal charges of sending pornography and sexually explicit messages to a 15-year-old girl.

Weiner pleaded guilty to sending obscene material to a minor in May, with prosecutors recommending a sentence of 27 months in prison. He will also have to register as a sex offender.

Weiner referred to the 2016 sexts as his “rock bottom” in a weepy statement to the judge.

“Now I focus on how to live my new, smaller life, one day at a time,” he said, voice breaking. “I have a disease, but I have no excuse.”

Weiner said he goes to therapy twice a week and meetings every day to keep his sex addiction under control. Weiner’s lawyers said minors weren’t the focus of his sexual compulsions, and with treatment he stood posed to lead a better life. They asked for probation given the unusual circumstances of his offense.

“The victim made a decision to encourage Anthony Weiner to engage in his infamous behaviors to make a profit—which she did,” attorney Arlo Devlin-Brown claimed, adding the girl was “looking to capitalize on his compulsions.” That is “different from seeking out victims to exploit,” he added.

Judge Denise Cote said the girl’s supposed motives were irrelevant.

“They are irrelevant. She was a minor,” Cote said. “She is a victim. She is entitled to the law’s full protection.”

Weiner, 53, resigned from Congress after tweeting an explicit photo from his account in 2011. Two years later, sexting revelations derailed his mayoral bid in New York. He continued his reckless behavior even after encountering a high-school student, and sexted with a Trump supporter while wife Huma Abedin was on the campaign trail with Hillary Clinton.

At the time, Abedin said she had forgiven her husband, and that the couple was “moving forward” with their young son.

Abedin finally filed for divorce after his guilty plea.

“Weiner, a grown man, a father, and a former lawmaker, willfully and knowingly asked a 15-year-old girl to display her body and engage in sexually explicit conduct for him online,” prosecutors wrote. “Such conduct warrants a meaningful sentence of incarceration.”

Judge Cote acknowledged Weiner’s apparent progress before handing down the sentence.

“But the difficulty here is that it is a very strong compulsion,” she said. “He’s made great strides, but it will be a challenge for years to come.”

“There is an opportunity to make a statement that will protect other minors,” Cote added.

Weiner is expected to begin his sentence November 6.