Tekashi 6ix9ine was released from federal prison Thursday after his attorney said the rapper's asthma made him vulnerable to the novel coronavirus.

The rapper, whose real name is Daniel Hernandez, will serve the rest of his sentence at home, his defense attorney Lance Lazzaro told CNN.

His release comes about four months before Hernandez would have completed his 2-year sentence. He was sentenced late last year on charges related to gang activity in New York, but received a reduced sentence after cooperating with federal investigators and informing on his former gang associates.

The rapper is not the only inmate to be released amid the coronavirus pandemic.

In recent weeks, there's been a national push for the release of at-risk inmates as the number of coronavirus cases grows inside correctional facilities. U.S. Attorney General William Barr directed leaders of the federal prison system late last month to increase home confinement for some inmates.

Judge says he would have sentenced home confinement

Lazzaro filed a letter in federal court on March 22 asking that his client be released to avoid the risk of contracting COVID-19. Lazzaro reiterated in another letter on March 31 that Hernandez has "severe asthma and was recently hospitalized for bronchitis," making him vulnerable to the coronavirus.

New York District Judge Paul Engelmayer denied the request, stating he did not have the authority to grant the request. Hernandez, the judge said, should instead seek compassionate release from the Bureau of Prisons.

But the judge also indicated the sentence would have been different if he had known of the coming pandemic and the threat it posed to people with asthma, like Hernandez.

"Had the court known that sentencing Mr. Hernandez to serve the final four months of his term in a federal prison would have exposed him to a heightened health risk," Engelmayer wrote in the order, "the Court would have directed that these four months be served instead in home confinement."

But the BOP also denied the request because Hernandez is not in its custody. He is technically in the care of the U.S. Marshals Service in a private prison.

So Lazzaro went back to the judge, arguing Engelmayer did, in fact, have the authority to order Hernandez's release -- a claim backed by the U.S. Attorney's Office for the Southern District of New York, which prosecuted Hernandez's case.

U.S. Attorney Geoffrey S. Berman wrote in a letter to Engelmayer that the court would have the authority to reduce the sentence if it found "extraordinary and compelling reasons" related to the defendant's health, citing federal law. Additionally, Berman wrote the government "does not oppose" a compassionate release for Hernandez.