Updated at 12:05 p.m. ET

Anthony Weiner pleaded guilty Friday to criminal charges following revelations the former Democratic congressman exchanged sexually explicit messages with a 15-year-old girl.

“I have a sickness, but I do not have an excuse,” Weiner told the court during his plea Friday. Though Weiner has not yet been sentenced, the charge carries between zero to 10 years in prison, and he agreed not to appeal any sentence between 21 to 27 months. The judge accepted the plea, and informed Weiner that he would have to register as a sex offender.

The plea comes eight months after the British tabloid Daily Mail published an interview with the high-school sophomore from North Carolina, who detailed months of conversations between her and Weiner, including suggestive texts and photos. The minor told the newspaper she would not seek to press charges against the New York congressman because “she believes her relationship with Weiner was consensual,” but agreed to be interviewed “out of concern that Weiner may be sexting with other underage girls.”

The revelation led to Weiner’s separation from his wife, Huma Abedin, who at the time was serving as the top aide to Democratic presidential candidate Hillary Clinton (she formally filed for divorce from Weiner on Friday). It also prompted the launch of a formal investigation into the matter, during which the FBI seized Weiner’s electronic devices, including a laptop computer that contained several emails to Abedin. The discovery led to an announcement by then-FBI Director James Comey in late October that bureau would conduct a new investigation into Clinton’s use of a private email serves as secretary of state. The FBI’s investigation did not result in any charges, though Clinton has since claimed the move contributed to her failed presidential bid.

Though Weiner originally denied the allegations, claiming he had “likely been the subject of a hoax,” he also apologized for having “repeatedly demonstrated terrible judgement about the people I have communicated with online and the things I have sent.” Indeed, this is not the first sexting scandal that has embroiled Weiner’s political career. He resigned from Congress in 2011 after first denying, then admitting, to sending explicit photos to women on Facebook and Twitter. He faced another sexting scandal during his bid for New York mayor in 2013, during which it was revealed he had continued to send explicit photos and texts using the pseudonym “Carlos Danger.”