Former New York congressman Anthony Weiner, the disgraced politician whose 'sexting' scandals shattered his career, admitted Friday in federal court to sending sexual material to a 15-year-old girl.

Weiner, 52, pleaded guilty to transferring obscene material to a minor - a crime that will require him to register as a sex offender and could mean years in prison.

"I have a sickness, but I do not have an excuse," he told the court. "I apologize to everyone I have hurt. I apologize to the teenage girl, whom I mistreated so badly."

The day was marked by an emotional courtroom confession and news that Weiner's estranged wife, Huma Abedin, filed for divorce after a separation that began last year amid the evolving sex scandal. A spokesperson with the Manhattan Supreme Court confirmed that Abedin, a close aide to Hillary Clinton, had filed court papers seeking a divorce.

The criminal case involving the 15-year-old girl came to light in September, following several incidents in recent years in which Weiner was accused of inappropriate communications with women online.

Federal authorities said that Weiner started communicating with the teen in January 2016 through online text and video chat applications, sending her sexually explicit images and asking her to engage in sexual conduct, according to a statement from the U.S. Attorney's Office for the Southern District of New York.

He surrendered to FBI agents in New York early Friday and appeared in court late-morning, telling U.S. District Judge Loretta Preska how he had communicated with the teenager, "as I had done and continued to do with adult women," according to his plea statement, which was released by his attorney. "I knew this was as morally wrong as it was unlawful."

Weiner, a Democrat who represented a New York City congressional district for more than a decade, resigned in 2011 amid a firestorm over an explicit photo he accidentally sent from his Twitter account. Weiner later admitted that he had exchanged explicit messages and photos with at least six other women.

Weiner said in court Friday that he has "compulsively sought attention" from women who have reached out to him on social media and that he has engaged some of them in sexual conversations.

"These destructive impulses brought great devastation to family and friends, and destroyed my life's dream of public service," he said in his plea statement. "And yet I remained in denial even as the world around me fell apart."

Following the incident with the 15-year-old girl, Weiner said, "I came to grips for the first time with the depths of my sickness" and started mental health treatment.

Weiner teared up as he made his statement, the Associated Press reported.

After Weiner pleaded guilty in the case, his attorney, Arlo Devlin-Brown, said his client has accepted "full responsibility for the inappropriate, sexually explicit communications he engaged in early last year."

"He apologized, offered no excuses, and made a commitment to make amends," Devlin-Brown said in a statement.

The criminal charge - transferring obscene material to a minor - carries a maximum penalty of 10 years in prison, according to federal authorities. Under the plea deal, Weiner agreed to register as a sex offender and not to appeal a sentence between 21 and 27 months in prison. His sentencing hearing is set for Sept. 8.

"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 H. Kim said in a statement.

The case came to the attention of the FBI last year when the 15-year-old girl in North Carolina told the Daily Mail about her online communications with Weiner. The story claimed Weiner carried on a months-long online sexual relationship with "a troubled 15-year-old girl" and that he had been asking her "to dress up in 'school-girl' outfits and pressing her to engage in 'rape fantasies.'"

During a federal investigation, agents seized a laptop that Weiner had shared with Abedin. On the laptop, agents discovered numerous emails that Clinton had sent to Abedin, prompting an announcement from then-FBI Director James Comey in the days leading up to the presidential election that the agency was reopening its investigation into Clinton's emails.

Comey then announced that no charges would be brought in the case. But Clinton, and others, have said the scandal was partly the reason she lost the presidential election to Donald Trump.