NEW YORK -- (WPIX) -- Former U.S. Rep. Anthony Weiner, whose penchant for sexting strangers ended his political career, pleaded guilty Friday to criminal charges in connection with his online communications with a 15-year-old girl.
"I have a sickness, but I do not have an excuse and I accept full responsibility and I apologize to the teenager who I abused," Weiner said in a statement, crying throughout.
Weiner pleaded guilty to a charge of transmitting sexual material to a minor and could get years in prison. He agreed not to appeal any sentence between 21 and 27 months in prison.
Weiner was already in federal custody ahead of the hearing. The judge told him he would have to register as a sex offender.
The disgraced politician told the court: “I knew that what I was doing was morally wrong and unlawful," before apologizing to his victim.
Weiner will be sentenced Sept. 8, and has agreed not to appeal if it is less than 27 months.
In addition to registering as a sex offender, he is required to continue treatment, which he said he began last fall.
“This fall I finally came to grips with the depth of my sickness. … I had hit rock bottom and entered treatment,” Weiner said during his statement.
The FBI began investigating Weiner in September after the North Carolina girl told a tabloid news site that she and the disgraced former politician had exchanged lewd messages for several months.
She also accused him of asking her to undress on camera.
The investigation led FBI agents to seize his laptop computer, which led to the discovery of a new cache of emails that Democratic presidential candidate Hillary Clinton had sent to Huma Abedin, Weiner's wife.
In October, just days before the election, FBI director James Comey stunned the country by announcing that his agency was reopening its closed investigation into Clinton's handling of State Department business on a private email server so it could analyze the newly discovered correspondence.
That inquiry was brief. Comey announced shortly before the election that the new emails contained nothing to change his view that Clinton could not be charged with a crime. But Clinton partly blamed her election loss to Republican Donald Trump on Comey's announcement.
Weiner's lawyer, Arlo Devlin Brown, didn't immediately return a message Friday.
Weiner also is a former New York mayoral candidate. He quit Congress in 2011 following revelations he was sending women sexually explicit messages.
After repeated episodes of sexting scandals, including one with an underage girl, Weiner reportedly checked into a rehab center for sex addiction.
The Associated Press contributed to this report.