US President Donald Trump's ex-lawyer Michael Cohen has been released from prison after a judge ruled he was sent back to jail in retaliation for writing a tell-all book.
The judge ordering his release said the government was retaliating when it sent Cohen back to prison this month.
He had been released in May over Covid-19 concerns.
Cohen was serving a three-year sentence for charges including Trump campaign finance violations.
Cohen is expected to be fitted with an ankle tag and will serve the rest of the sentence at home in New York City.
"He looked exhausted, as one might think, when you come out of quarantine/solitary confinement," his attorney, Jeffrey Levine, told the Reuters news agency after speaking to Cohen over FaceTime from the car.
"He hasn't slept in two weeks."
You might also like
Cohen was convicted last year of crimes including tax evasion, lying to Congress and facilitating illegal payments to silence two women - pornographic film star Stormy Daniels and former Playboy model Karen McDougal - who claimed they had affairs with Mr Trump.
After his May release, authorities this month said Cohen violated the terms of his release.
Cohen argued his re-arrest was retaliation for his plans to publish a critical book about Donald Trump.
He said that probation officers had asked him to sign a release agreement that would prohibit him from speaking to, or through, any media. When he questioned this order, he was taken back into custody.
US Judge Alvin Hellerstein issued the ruling during a tele-hearing on Thursday.
He said that Cohen's return to jail was "retaliatory because of his desire to exercise his First Amendment rights to publish a book and to discuss anything about the book or anything else he wants on social media and with others".
The Manhattan judge added that, in 21 years on the bench, he had never seen such a provision for a prisoner. "How can I take any other inference but that it was retaliatory?"
Cohen was re-arrested on 9 July - days after he tweeted that he was "close to completion" of his tell-all book relating to the president. The book reportedly details alleged racist comments made by Mr Trump.
This week, Cohen had sued US Attorney General William Barr and the prison bureau director over the so-called "gag order".
The suit, brought by Cohen's attorneys and the American Civil Liberties Union (ACLU), claimed that Cohen's re-jailing over the order violated his constitutional right to free speech.
According to court filings, Cohen's book would provide "graphic and unflattering details about the President's behaviour behind closed doors", including descriptions of his "pointedly anti-Semitic remarks and virulently racist remarks" against former President Barack Obama and Nelson Mandela.
The White House has not yet commented on these allegations.