WASHINGTON (AP) — A federal judge ordered the Trump administration on Friday to immediately return the White House press credentials of CNN reporter Jim Acosta, though a lawsuit over the credentials' revocation is continuing.

U.S. District Court Judge Timothy Kelly, an appointee of President Donald Trump, announced his decision at a hearing Friday morning. The judge said Acosta's credentials must be reactivated to allow him access to the White House complex for press briefings and other events.

Acosta, CNN's chief White House correspondent, was back in the afternoon. The White House said it would be developing new rules for orderly press conferences.

The White House revoked Acosta's credentials last week after he and Trump tangled verbally during a press conference following the midterm elections. CNN sued and asked the judge to issue a temporary restraining order forcing the White House to give back Acosta's credentials. The judge agreed.

CNN alleged that Acosta's First and Fifth Amendment rights were violated when the White House revoked his "hard pass."

While the judge didn't rule on the underlying case, he ordered Acosta's pass returned for now in part because he said CNN was likely to prevail on its Fifth Amendment claim — that Acosta hadn't received sufficient notice or explanation before his credentials were revoked or been given sufficient opportunity to respond before they were.

The judge said the government could not say who initially decided to revoke Acosta's hard pass and how that decision was reached.

"In response to the court, we will temporarily reinstate the reporter's hard pass," White House press secretary Sarah Huckabee Sanders said in a statement. "We will also further develop rules and processes to ensure fair and orderly press conferences in the future."

Speaking to reporters after the decision, Trump said, "If they don't listen to the rules and regulations, we will end up back in court and we will win."

Story continues

He later added: "We want total freedom of the press. It's very important to me, more important to me than anybody would believe. But you have to act with respect when you're in the White House, and when I see the way some of my people get treated at press conferences, it's terrible. So we're setting up a certain standard, which is what the court is requesting."

The White House had spelled out its reasons for revoking Acosta's credentials in a tweet from Sanders and in a statement after CNN filed its lawsuit. But the judge said those "belated efforts were hardly sufficient to satisfy due process."

But the judge also emphasized the "very limited nature" of his ruling Friday. He noted he had not determined that the First Amendment was violated.

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

On Friday afternoon, more than 50 members of the White House press corps greeted Acosta as he strode through the northwest gate of the presidential compound. He said he was grateful for the judge's ruling, that it was a test and the media passed the test.

"This is just any other day at the White House for me and I would like to get back to work," he said.

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, 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 handheld 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."

Hours later, the White House pulled Acosta's credentials.

The White House's explanations for why it seized Acosta's credentials have shifted over the past 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 in a written statement of being unprofessional by trying to dominate the questioning at the news conference.