Anthony Weiner, the former congressman convicted of sexting with a 15-year-old girl, has been released from a federal prison in Massachusetts to a transitional facility in New York and must register as a sex offender.

Weiner, 54, pleaded guilty in May 2017 to transferring obscene material to a minor. Four months later, he was sentenced to 21 months in federal prison.

The Federal Bureau of Prisons website says Weiner was transferred from the Federal Medical Center in Devens to a Residential Re-Entry Management facility in Brooklyn. Weiner, who has a release date of May 14, most likely will serve out his time in a halfway house or home confinement.

Weiner must register as a sex offender and spend three years of supervised release.

Prosecutors said the teen initiated the communications with Weiner via Twitter in January 2016. The girl acknowledged she was a minor, but the contacts continued over Snapchat and other social media outlets.

More:I was 'a very sick man': Tearful Anthony Weiner gets 21 months in sexting case

Even after the girl told Weiner that she was 15, Weiner asked her to show him her naked body, which she did, prosecutors said. He also sent her pornography.

Weiner wept at his sentencing, saying he was sorry and that he was “a very sick man for a very long time.”

"The crime I committed was my rock bottom," Weiner said. "I live a different and better life today."

U.S. District Court Judge Denise Cote, however, rejected Weiner's request to avoid jail.

“This is a serious crime that deserves serious punishment," Cote said.

Weiner was elected to Congress from Brooklyn in 1998 and served 12 years in the heavily Democratic district. In 2010, his star rose after making a dramatic speech before Congress in which he blasted Republicans for voting against a federal aid bill for first responders to the 9/11 terror attacks.

Weiner married Huma Abedin, a longtime aide to Hillary Clinton, in 2010. The power couple had a son in 2011. But he resigned his seat that year after admitting he had been exchanging explicit messages and photos with a half-dozen women.

He attempted a comeback in 2013 via a mayoral campaign that collapsed when it emerged he was sending explicit photos to a 22-year-old woman under the pseudonym "Carlos Danger."

Abedin separated from Weiner in 2016 and filed for divorce after his guilty plea. The relationship became a crucial factor in the 2016 presidential campaign when then-FBI director James Comey reopened an investigation into Clinton emails less than two weeks before Election Day. The FBI cited a batch of emails discovered in the Weiner probe.

Days later, the FBI said nothing new or damaging against Clinton had been discovered.