Disgraced former Rep. Anthony Weiner was sentenced Monday to 21 months in prison, facing the most severe penalty yet in connection with the sexting scandal that drove the New York Democrat out of Congress, ruined his marriage and became a late issue in the 2016 presidential race.

U.S. District Judge Denise L. Cote issued the sentence in federal court in New York.

“This is a serious crime that deserves serious punishment,” Cote said in a statement.

The former lawmaker's sexting habits entered criminal territory with his illicit contact with a 15-year-old girl. Weiner, 53, had pleaded guilty in May to sending sexually explicit texts to the girl across state lines. Weiner agreed not to appeal any sentence between 21 and 27 months in prison.

Weiner openly wept in court on Monday as the judge announced the sentence. In addition to the prison term, he was sentenced to three years of supervised release, given a $10,000 fine, and required to forfeit his iPhone. Weiner must surrender on Nov. 6 to a yet-to-be determined prison facility.

Weiner read from a prepared statement for several minutes, describing himself as “an addict” and calling his crime “rock bottom.” He said he has a “disease,” but it is not an “excuse.”

The disgraced politician earlier had apologized in court to the teenage victim, blaming his own “destructive impulses.” Weiner also was forced to register as a sex offender.

“Anthony Weiner, a former Congressman and candidate for Mayor, asked a girl who he knew to be 15 years old to display her naked body and engage in sexually explicit behavior for him online. Justice demands that this type of conduct be prosecuted and punished with time in prison,” Acting Manhattan U.S. Attorney Joon H. Kim said in a statement Monday. “Today, Anthony Weiner received a just sentence that was appropriate for his crime.”

Weiner said last week that he was undergoing treatment and is profoundly sorry for subjecting the minor to what his lawyers call his “deep sickness.”

Weiner's treatments include individual therapy once a week, group therapy once a week, and 12-step meetings four to five times a week.

ANTHONY WEINER SCANDALS: FROM POLITICS TO SEXTING CASES

“I have compulsively sought attention from women who contacted me on social media, and I engaged with many of them in both sexual and non-sexual conversation,” Weiner said in a prepared statement in May. “These destructive impulses brought great devastation to my family and friends, and destroyed my life’s dream of public service.”

Throughout the trial, defense lawyers had portrayed the girl as an aggressor, saying she wanted to generate material for a book and possibly influence the presidential election.

Weiner apologized to his now-estranged wife, longtime Clinton aide Huma Abedin, and his family, after his admission of guilt. Abedin filed for divorce just hours after Weiner pleaded guilty in May.

The FBI began investigating Weiner in September 2016 after the 15-year-old girl in North Carolina told a tabloid news site that she and the former politician had exchanged lewd messages for several months, and accused him of asking her to undress on camera.

This relationship was hardly the first that caused public embarrassment for Weiner and his family. In 2011, Weiner resigned from Congress after an errant tweet exposed his sexting habits. He later ran for New York City mayor, but was unsuccessful.

But the criminal investigation into his relationship with the minor infamously intersected with the 2016 presidential election, when agents acquired Weiner’s electronic devices and uncovered a new batch of emails between Hillary Clinton and Abedin.

The discovery led the FBI to revisit the investigation into Clinton’s use of a private email server while conducting official government business while secretary of state. Clinton has cited this as a factor in her 2016 presidential defeat, and most recently, recalled the series of events in her new book, “What Happened.”

Fox News' Tamara Gitt and the Associated Press contributed to this report.