NEW YORK (AP) — Former Rep. Anthony Weiner was sentenced Monday to 21 months in prison for sexting with a 15-year-old girl in a case that rocked Hillary Clinton’s campaign for the White House in the closing days of the race and may have cost her the presidency.

Weiner, 53, dropped his head into his hand and wept as the sentence was announced by Judge Denise Cote. He must surrender to prison officials by Nov. 6.

The sentencing completed the sordid downfall of the New York Democrat, whose penchant for exchanging lewd messages and photos with young women online destroyed his career in Congress in 2011, doomed his bid for mayor of New York in 2013, wrecked his marriage to Clinton’s closest aide, Huma Abedin, and became entangled in the 2016 presidential campaign.

Admitting “I have a sickness, but I do not have an excuse,” Weiner pleaded guilty in May to transferring obscene material to a minor, punishable by up to 10 years in prison, for illicit contact with a North Carolina teenager.

He sought to be spared from prison, tearfully telling Cote on Monday that he was “a very sick man for a very long time.” Weiner, weeping as he read from a written statement on a page he held in front of him, called his crime his “rock bottom.”

Prosecutors said he sent her porn and got her to take her clothes off and touch herself on Skype. Assistant U.S. Attorney Amanda Kramer on Monday urged Cote to give Weiner a significant prison sentence to end his “tragic cycle” of sexting.

The FBI was investigating Weiner’s contact with the high school student when it came across emails on his laptop between Abedin and Clinton, prompting then-FBI Director James Comey to announce in late October 2016 that he was reopening the probe of Clinton’s use of a private computer server.

Two days before Election Day, the FBI announced there was nothing new in the emails. But Clinton has blamed Comey’s handling of the episode more than any other factor for her loss to Donald Trump. In a recent NBC interview, she called the FBI director’s intervention “the determining factor” in her defeat.

Weiner’s lawyers had argued in court papers that he was undergoing treatment and was profoundly sorry for subjecting the girl to his “deep sickness.” They also portrayed her as an instigator, saying she wanted to generate material for a book and possibly influence the presidential election.

Prosecutors responded by arguing the victim’s motives were irrelevant to the punishment and said Weiner’s habit of getting caught sexting “suggests a dangerous level of denial and lack of self-control.”

Weiner, wearing his wedding ring, seemed pensive just before Monnday’s hearing began. His parents were in the courtroom but not his wife. He and Abedin are currently going through divorce proceedings.

Weiner’s behavior in all its lurid detail — including his online alias “Carlos Danger” and a selfie of his bulging underwear — turned him and his last name into an irresistible punchline for late-night comics and mortified his wife again and again. The couple, who have a 5-year-old, are getting divorced.

In her new memoir, “What Happened,” Clinton revealed that Weiner’s wife “looked stricken” and burst into tears upon learning her husband had triggered Comey’s “October surprise.”

“This man is going to be the death of me,” Abedin was quoted as saying.