© Brendan McDermid / Reuters
Former US Congressman Anthony Weiner exits US Federal Court in New York City, May 19, 2017
Former US Congressman Anthony Weiner has pleaded guilty in federal court to one count of sending obscene messages to a minor. The "sexting" case played a part in the 2016 presidential election. Huma Abedin, Weiner's wife, also filed for divorce on Friday.

On Friday, in an appearance in US District Court in New York, Weiner, 52, agreed as part of his plea deal to not appeal any prison sentence of 27 months or less, according to reports. The charge comes with a potential of up to 10 years in prison.

He was emotional before the judge Friday, according to NBC News, saying, "I have a sickness, but I do not have an excuse."

Weiner surrendered to the FBI on Friday morning, the New York Times reported.

The plea deal covers a period from January through March of last year, when Weiner is alleged to have exchanged sexually explicit messages with a 15-year-old girl in North Carolina. Weiner is believed to have known the girl was underage.

Weiner read a prepared statement to the court after answering the judge's questions.

"Through approximately March 2016, I engaged in obscene communications with this teenager, including sharing explicit images and encouraging her to engage in sexually explicit conduct, just as I had done and continued to do with adult women," Weiner said. "I knew this was as morally wrong as it was unlawful."

The girl has said the relationship was "consensual" and that she did not want to press charges. Yet she agreed to be interviewed, with her father, "out of concern that Weiner may be sexting with other underage girls."

Weiner will be required to register as a sex offender, NBC News reported. He said Friday that he has apologized to the girl and has entered "intensive treatment" in the process of understanding the "depths of my sickness."

He was released on bail pending a September 8 sentencing.

"Weiner's conduct was not only reprehensible, but a federal crime, one for which he is now convicted and will be sentenced," acting Manhattan U.S. Attorney Joon Kim said in a statement.

The former rising star in the Democratic Party saw his career as a US congressman come to a halt in June 2011. He resigned from his seat after he was revealed to have sent explicit photos of himself to several women.

He then ran for New York City mayor in 2013, but that campaign was derailed by further revelations of explicit messaging with women.

Weiner and wife Huma Abedin, a longtime aide to former Democratic presidential candidate Hillary Clinton, separated after new explicit photos were exposed in August 2016. Abedin officially filed for divorce on Friday, according to the New York Post.

During its investigation of Weiner, the FBI seized his electronic devices, including a laptop with emails to Abedin. The emails prompted then-director of the FBI James Comey to announce in October, just prior to Election Day, that the bureau was opening a new inquiry into Clinton's email correspondence policies while she was US secretary of state.

That investigation ended two days before the election, yielding no charges while outraging the Clinton campaign and its backers.

Earlier this month, Comey told a Senate committee that Abedin regularly emailed classified documents to Weiner, though he said he does not believe any crimes were committed and that the documents were forwarded as a "matter of convenience."

"His then-spouse, Huma Abedin, appears to have had a regular practice of forwarding emails to him for him, I think, to print out for her so she could then deliver them to the secretary of state [Clinton]," Comey said on May 3, just days before President Donald Trump announced he would replace Comey as head of the FBI.