Former US Rep. Anthony Weiner was ordered Friday to register as a sex offender as he nears the end of a 21-month prison sentence for having illicit online contact with a 15-year-old girl.

A New York City judge designated Weiner a Level 1 offender under the state's version of what's known as Megan's Law, meaning that he is thought to have a low risk of reoffending.

Weiner, a once-rising star in the Democratic Party who served nearly 12 years in Congress, has been living in a halfway house since February after serving most of his sentence at a prison in Massachusetts.

He's due to be released May 14 but still faces three years of court supervision.

Weiner, 54, must register for a minimum of 20 years. He is required to verify his address every year, notify the state within 10 days of moving and visit a police station every three years to have a new picture taken.

Because of his low-level designation, Weiner's information won't show up in the state's online sex offender registry but will be available via a toll-free telephone number.

Former US Rep Anthony Weiner has been ordered to register as a sex offender as he nears the end of a 21-month prison sentence for sexting a 15-year-old girl (file photo)

Weiner didn't attend Friday's court hearing. Messages seeking comment were emailed to his lawyers.

Weiner pleaded guilty in May 2017 to transferring obscene material to a minor after DailyMail.com revealed he'd sent a series of sexually explicit messages to a North Carolina high school student.

Weiner pleaded guilty in May 2017 to transferring obscene material to a minor after DailyMail.com revealed he'd sent a series of sexually explicit messages to a North Carolina high school student

At his sentencing, Weiner said he'd been a 'very sick man for a very long time' and said he had a sex addiction.

Weiner's lawyer said the former lawmaker likely exchanged thousands of messages with hundreds of women over the years and was communicating with up to 19 women when he encountered the teenager.

It wasn't the first time Weiner had been caught acting inappropriately.

After sending a lewd picture of himself to a college student in 2011, Weiner claimed his account had been hacked, then admitted online interactions with at least six other women while married to top Hillary Clinton aide Huma Abedin.

Weiner resigned from Congress, only to try for a political comeback with a run for New York City mayor in 2013. Then came the revelation that Weiner had used the alias 'Carlos Danger' to send explicit photos to at least one woman after resigning from Congress.

Weiner received less than five percent of the Democratic primary vote.

Abedin filed for divorce from Weiner in 2017. But the two, who have a young son together, later agreed to discontinue the case in order to negotiate their separation privately.