WASHINGTON (AP) — A federal judge ordered the Trump administration on Friday to immediately return the White House press credentials of CNN reporter Jim Acosta, saying Acosta suffered "irreparable harm" from the decision to bar him.

U.S. District Court Judge Timothy Kelly, an appointee of President Donald Trump, announced his decision following a hearing. The judge said Acosta's credentials would be returned immediately and reactivated to allow him access to the White House.

CNN had asked the judge to force the White House to return the credentials that give Acosta, CNN's chief White House correspondent, access to the White House complex for press briefings and other events.

The judge granted CNN's request for a temporary restraining order. A lawsuit that CNN brought against the Trump administration over the issue is continuing.

The White House revoked Acosta's credentials after he and Trump tangled during a press conference last week.

The judge said the government could not say who initially decided to revoke Acosta's hard pass. The White House had spelled out its reasons for revoking his credentials in a tweet from White House Press Secretary Sarah Huckabee Sanders and in a statement after CNN filed its lawsuit. But the judge said those "belated efforts were hardly sufficient to satisfy due process."

The judge also found that Acosta suffered "irreparable harm," dismissing the government's argument that CNN could simply send other reporters to cover the White House in Acosta's place.

The suit by CNN alleges that Acosta's First and Fifth Amendment rights were violated by suspending his hard pass. While the judge didn't rule on the underlying case, he signaled they were likely to prevail in their claims.

The judge told attorneys to file additional court papers in the case by Monday.

"Let's go back to work!" Acosta said outside the courthouse after the ruling.

Trump has made his dislike of CNN clear since before he took office and continuing into his presidency. He has described the network as "fake news" both on Twitter and in public comments.

At last week's press conference, which followed the midterm elections, Trump was taking questions from reporters and called on Acosta, who asked about Trump's statements about a caravan of migrants making its way to the U.S.-Mexico border. After a terse exchange, Trump told Acosta, "That's enough," several times while calling on another reporter.

Acosta attempted to ask another question about special counsel Robert Mueller's Russia investigation and initially declined to give up a hand-held microphone to a White House intern. Trump responded to Acosta by saying he wasn't concerned about the investigation, calling it a "hoax," and then criticized Acosta, calling him a "rude, terrible person."

The White House pulled Acosta's credentials hours later.

The White House explanations for why it seized Acosta's credentials have shifted over the last week.

Sanders initially explained the decision by accusing Acosta of making improper physical contact with the intern seeking to grab the microphone.

But that rationale disappeared after witnesses backed Acosta's account that he was just trying to keep the microphone, and Sanders distributed a doctored video that made it appear Acosta was more aggressive than he actually was. On Tuesday, Sanders accused Acosta of being unprofessional by trying to dominate the questioning at the news conference.