Anthony Weiner, who resigned from Congress in 2011 over a sexting scandal, pleaded guilty Friday to federal charges of transmitting sexual material to a minor and could face a prison term.

The 52-year-old Democratic politician from New York will also have to register as a sex offender.

Weiner, who is separated from top Hillary Clinton aide Huma Abedin, appeared before a federal judge in a Manhattan court and agreed not to appeal any sentence between 21 and 27 months in prison.

The FBI began investigating Weiner in September after a 15-year-old North Carolina girl told the Daily Mail, a British tabloid, that she and Weiner exchanged lewd messages for several months. She also accused him of asking her to undress on camera.

The charge carries a potential sentence of up to 10 years in prison, but could involve no jail time depending on the determination of a judge.

The latest incident spilled over into the presidential race when investigators, who seized Weiner's laptop computer, found a cache of purportedly new emails that Democratic presidential candidate Hillary Clinton sent to Abedin. The emails had apparently been forwarded to the computer or transferred there for printing or storage.

The incident prompted then FBI director James Comey to state publicly — in the final weeks of the presidential campaign — that the closed investigation into Clinton's alleged mishandling of classified material was being reopened. He later said the emails were duplicates of earlier material already examined by the FBI.

Weiner ran unsuccessfully for mayor of New York in 2013 in a campaign that collapsed when Weiner, using the alias "Carlos Danger," again was found to be sending explicit photographs. The failed mayoral bid is the subject of the documentary Weiner.

Contributing: Associated Press