Michael Cohen, a former personal lawyer to President Trump, was released from federal prison to home confinement Thursday as part of the Justice Department’s push to stem the spread of the coronavirus among inmates.

Jeffrey Levine, Cohen’s attorney, confirmed the development after Cohen was spotted leaving the facility in Otisville, N.Y. Cohen later wrote on Twitter: “I am so glad to be home and back with my family. There is so much I want to say and intend to say. But now is not the right time. Soon. Thank you to all my friends and supporters.”

The move, although expected, is likely to rile Trump, who has derided his former lawyer as a “rat.” Cohen, 53, of New York City, once affectionately considered himself Trump’s “fixer,” but as he became ensnared in multiple federal investigations, Cohen turned on his former client — cooperating with federal investigators scrutinizing the president, and airing out in federal court and before Congress what he viewed as Trump’s misconduct.

Cohen’s release did not come easy, and it served to highlight ongoing dysfunction in how the Bureau of Prisons has implemented Attorney General William P. Barr’s directive to prioritize the use of home confinement to prevent covid-19 outbreaks in federal detention facilities.

Cohen had expected to get out May 1, after being placed in a two-week prerelease quarantine meant to ensure he wouldn’t bring the virus to the outside world. But as he waited, officials changed course, deciding he would have to meet new Bureau of Prisons criteria that inmates prioritized for release must first have served 50 percent of their sentence, or have served 25 percent and have 18 months or less remaining.

That has not been the case for everyone. Former Trump campaign chairman Paul Manafort, for example, was released from prison last week without having met either set of criteria. Legal advisers complained publicly about the reversal, fueling speculation that Cohen was being singled out for harsh treatment because of his soured relationship with Trump. Cohen remained in quarantine, waiting to hit the lower threshold — which, with good behavior time, he would do later in the month.

“As I write this letter Mr. Cohen remains in solitary with no change of clothing, showers once every three days, drinking dirty water from a rusty faucet in his cell, inedible food and his blood pressure/hypertension is not well controlled by medication prescribed by the prison physician,” Levine wrote in a letter on the day Cohen was not released as expected.

The disorganization at the Bureau of Prisons has not been limited to Cohen. Inmates in several institutions have complained that the agency has issued shifting, sometimes contradictory directives about who should be released, and applied the rules inconsistently.

Cohen pleaded guilty in 2018 in two separate criminal cases. In the first, he admitted to campaign finance violations stemming from payments made before the 2016 election to women who alleged having affairs with Trump years earlier. The president has denied their claims. In the second, Cohen admitted to lying to Congress about a Moscow real estate project Trump and his company pursued while Trump was trying to secure the Republican presidential nomination.

Cohen blamed Trump for his wrongdoing, saying that he arranged the payments at Trump’s direction to keep the women quiet, and that he lied to lawmakers about the real estate project to protect his boss. Trump has disputed his account.

U.S. District Judge William H. Pauley III sentenced Cohen to three years in prison, and Cohen reported to the institution in Otisville on May 6, 2019. In March, Pauley rejected Cohen’s bid to be released early because of the pandemic.

But the coronavirus-relief legislation Congress passed gave Barr the authority to declare an emergency and allow prison officials to release inmates to home confinement without judicial approval. That gave Cohen another chance.

A Bureau of Prisons spokeswoman said Cohen had been released “on furlough” pending his formal processing for home confinement.

Since Barr directed in late March that the Bureau of Prisons prioritize the use of home confinement to stem the spread of the coronavirus, officials have released thousands of people. Thousands of federal inmates have contracted the coronavirus, and more than 50 have died.

The bureau’s decisions on who gets out, though, have sparked considerable controversy. That was especially true for Manafort, who had been imprisoned since 2018 and was serving a term of more than seven years.

Manafort had been indicted by special counsel Robert S. Mueller III on a charge of witness tampering while awaiting trial on bank and tax fraud charges, for which he was convicted in summer 2018. Manafort also later pleaded guilty to conspiracy to defraud the United States and obstruct justice related to his undisclosed lobbying for a pro-Russian politician and political party in Ukraine.

A Justice Department official said that although Manafort, 71, had not served enough time to be granted priority release, the Bureau of Prisons thought it was necessary because of his age and vulnerability, given his underlying health conditions. Prison officials have discretion to deviate from the requirements on time served, the official said.

Cohen has similarly said that he has health problems, including “a history [of] pulmonary embolisms, respiratory deficiencies, cardiac concerns and high blood pressure,” according to information provided by a legal adviser.