EXCLUSIVE

Anthony Weiner is no longer behind bars, but the disgraced ex-U.S. Congressman still has a few months in federal custody before he's freed ... still earlier than originally expected.

Law enforcement sources tell TMZ ... Weiner's been transferred out of a Massachusetts prison and into the custody of a Bureau of Prisons residential re-entry center in New York. We're told he's either in a halfway house or home confinement.

Weiner's now in pre-release status, which inmates often get as they approach the end of their federal sentence. The purpose is to prepare them to transition back into society.

As we reported ... Weiner started serving his 21-month prison sentence in November 2017 after pleading guilty to sexting with a 15-year-old girl in North Carolina. He was slated to get out August, 2019, but good behavior slashed the sentence 3 months to May 14.

We're told that is still his scheduled release date.

Weiner served his time at the Federal Medical Center in Devens, Massachusetts where they offer treatment for sex offenders. As you know ... Weiner has a long, scandalous history.

Weiner resigned from Congress after his first sexting scandal in 2011. He ran for NYC mayor but that bid was derailed in 2013 when he was found sexting Sydney Leathers under the infamous alias, "Carlos Danger."