A rising music star and internet personality once known for his long rainbow-colored locks, Mr. Hernandez, who grew up in Brooklyn, had a multiplatinum hit song, “Fefe,” with Nicki Minaj in 2018, and signed a $10 million record contract shortly before he was sentenced last December. His persona was built around boasts that he could outrun the law even as he live streamed videos of himself with guns and taunted rival gangs online. But after he was arrested on firearms and racketeering charges in November 2018, Mr. Hernandez began speaking with the government and agreed to testify for the prosecution against his former gang mates.

Mr. Hernandez, prosecutors noted, turned against Nine Trey Gangsta Bloods — a faction of the Bloods — at great personal risk. As a result, he was held in a private prison that was run by U.S. Marshals, his lawyer said, and the location of his home confinement could not be revealed. The paperwork that related to his release was not filed publicly until he was in his new residence, to “ensure the safety of law enforcement agents and Mr. Hernandez upon his release from custody,” according to a letter from the Justice Dept. to the courts.

Mr. Hernandez had previously rejected the idea of entering the witness protection program, saying he planned to continue making music upon his release, which is set for July 31 (he was given credit for time served at his sentencing).

“He has no intention of going into” witness protection, Mr. Lazzaro said on Thursday. “He hopes to resume his career.”

The rapper’s release comes as prison reform advocates and some health officials are sounding an alarm about a potential disaster among the incarcerated, citing the impossibility of social distancing in prison cells, the banning of hand sanitizer, and the likelihood that corrections officers would spread the illness in their communities, as the virus catches on. Thousands of inmates and officers in municipal, state and federal facilities have already tested positive, and at least five inmates at federal facilities have died because of the coronavirus outbreak since March 28, according to the Bureau of Prisons.

Since Attorney General William P. Barr wrote a letter on March 26, directing federal institutions to prioritize home confinement, the Bureau of Prisons has placed 471 inmates into residences, a spokesman said.