ERIK S LESSER/EPA-EFE/REX/Shutte

WASHINGTON — A federal judge ruled that the Trump administration must at least temporarily reinstate CNN correspondent Jim Acosta’s hard pass, delivering a victory to the network and other news organizations.

The judge, Trump appointee Timothy J. Kelly, granted CNN’s request for a temporary restraining order to restore Acosta’s access.

“I will order defendants immediately restore Mr. Acosta’s hard pass,” Kelly said from his bench at the U.S. District Court in Washington. The restraining order lasts for 14 days.

Kelly said CNN was likely to succeed on its claim that Acosta was not granted due process when his pass was pulled.

He cautioned that the ruling was limited and he was not yet making a determination on broader First Amendment concerns, such as on CNN’s claim that the decision to revoke Acosta’s pass was rooted in Trump’s dislike of his coverage or animus toward the news network.

In the courtroom, Acosta and Sam Feist, CNN’s Washington bureau chief, did not display any emotion as Kelly read through his ruling, but after he was finished, they shook hands with the network’s legal team, which is led by Ted Boutrous.

Outside the courtroom, Acosta spoke to reporters and thanked other journalists for their support in the case. “Now let’s go back to work,” he said.

He returned to the White House shortly after noon, where a large group of reporters and photographers were waiting to get his reaction.

“This was a test, and I think we passed the test,” he told them.

Press Secretary Sarah Huckabee Sanders said “the court made clear that there is no absolute First Amendment right to access the White House.” She said they would “further develop rules and processes to ensure fair and orderly press conferences in the future. There must be decorum at the White House.”

Trump echoed those remarks in speaking to pool reporters. “We have to practice decorum. We want total freedom of the press.” He added, “We’re setting up a certain standard which is what the court is requesting.”

Kelly made it clear that the Trump administration had to follow the precedent set by a 1977 D.C. Circuit Court opinion in Sherrill v. Knight, involving a reporter for the Nation who was denied a press pass by the Secret Service.

In that case, the D.C. Circuit held that “the protection afforded newsgathering under the first amendment guarantee of freedom of the press requires that this access [to White House press facilities] not be denied arbitrarily or for less than compelling reasons.”

Following a contentious, post-midterm press conference on Nov. 7, Acosta’s hard pass was pulled. The White House initially claimed that it was because he put his hands on a staffer as she tried to grab a microphone from him. Acosta denied that, and video of the incident shows that his hand only inadvertently touched her arm as she tried to get the mic.

In a filing on Wednesday, the Trump administration said they had a compelling reason to pull his pass — that he had disrupted the press event after refusing to yield the floor to another reporter.

Kelly said the Sherrill v. Knight opinion requires that the White House give proper notice of a revocation, and an opportunity for Acosta and CNN to respond. The administration claimed that it gave such notice, starting at the press conference when Trump called out Acosta for “rude” behavior, but Kelly found that was insufficient. He also said Sanders’ later statements about the matter were “belated” and “hardly sufficient to provide adequate due process.”

Kelly also noted that the action to revoke Acosta’s pass was “still so shrouded in mystery the government could not even tell me at oral argument who made the initial decision” to do so.

CNN argued that Acosta’s pass was pulled because of Trump’s animosity toward him and the network’s coverage, an arbitrary decision in violation of the First and Fifth amendments.

The Trump administration, represented by James Burnham and other attorneys from the Justice Department, contends that it is within the president’s discretion who gets access to the White House and who does not.

Although there may not be a First Amendment right to public access to the White House, Kelly said, the decision in Sherrill v. Knight established that members of the media have a right to due process. That is because portions of the White House complex are provided to the media, including work spaces for top news organizations, he said.

“I have no choice but to apply that principle here,” Kelly said.

Kelly also addressed Sanders’ initial claim that Acosta placed his hands on an intern as she tried to get a microphone from him. Acosta called it a “lie.” But Sanders later tweeted out a video appeared to be sped up and slowed down in parts, to highlight a moment when his hand touched her arm.

Sanders no longer is making the claim that Acosta improperly touched the intern, nor is the government. Kelly said the claim was “likely untrue” and was “partly based on evidence of questionable accuracy.”

Olivier Knox, the president of the White House Correspondents’ Association, said in a statement that the judge “made it clear that the White House cannot arbitrarily revoke a White House press pass. We thank all of the news outlets and individual reporters who stood up in recent days for the vital role a free and independent news media plays in our republic.”

The White House’s plans to create standards of decorum will be closely scrutinized by news outlets and journalism organizations, and may be challenged if they are vague and subjective. The Trump administration has not said what it plans to do next in the CNN case and whether it will try to pull Acosta’s credentials again after giving him proper notice.

In an interview with Fox News on Friday, Trump hinted at a different approach. He said, “Nobody believes in the First Amendment more than I do. And if think somebody is acting out of sorts, I will leave. I will say, ‘Thank you very much everybody. I appreciate you coming, and I will leave.’ And those reporters will not be too friendly to whoever it is who is acting up.”

RELATED VIDEO: