CNN on Friday won its legal battle against the Trump administration over its decision to revoke press credentials for White House reporter Jim Acosta.

U.S. District Court Judge Timothy Kelly, a Trump appointee, granted the network’s request for a temporary restraining order restoring Acosta’s White House press badge.

CNN sued the administration earlier this week in response to the White House’s decision to strip Acosta of his security credentials, which allow accredited journalists access to select areas of the White House.

Acosta had his pass revoked several hours after a heated exchange in which he pressed the president over his inflammatory rhetoric about immigrants, refusing to relinquish the microphone when a White House staffer attempted to take it away from him as the president berated him and called him a “rude, terrible person.”

In its lawsuit, the network said the White House’s actions violated the network and Acosta’s First and Fifth Amendment rights to free speech and due process. CNN argued Trump stripped Acosta of his access because of the questions he posed to the president; and that the White House failed to follow federal regulations dictating press-pass access.

In his decision, Judge Kelly said that under previous precedent set by a 1977 ruling, the White House “must provide due process if they are to revoke Mr. Acosta’s hard pass.”

Deputy Assistant Attorney General James Burnham, a lawyer for the administration, argued on Wednesday that Acosta had been disruptive, and the administration had a legal basis to vet reporters given press passes and bounce those they feel act disruptively.

But the judge found those arguments unconvincing. In fact, at one point during his ruling, Judge Kelly criticized the administration for its ever-changing defenses of its decision, including its short-lived and dubious claim that Acosta “laid his hands” on the female White House intern who tried to take the microphone from him—a claim of “questionable accuracy,” per Kelly.

While the judge temporarily restored Acosta’s press badge, he emphasized the “very limited” nature of the ruling. Kelly did not rule whether Acosta’s First Amendment rights were violated, and left open the possibility that Acosta may have his press pass legally revoked if offered appropriate due process.

In a statement following Friday’s hearing, CNN and Acosta said they were “gratified with this result and we look forward to a full resolution in the coming days.”

“Our sincere thanks to all who have supported not just CNN, but a free, strong and independent American press,” they said.

Acosta was seen outside the courtroom on Friday, saying, “Let’s get back to work,” following the ruling.

A senior Trump administration official said the press office had, anticipating Acosta's return under the order of a Trump-appointed judge, weighed the idea of simply not calling on the CNN correspondent for a while, if only to mess with him. (White House Press Secretary Sarah Huckabee Sanders has been holding vanishingly few official press briefings in recent months.)

Still, this doesn’t change the fact that Team Trump have for a long time considered Acosta a useful media foil and punching bag in the president's ongoing tiffs with mainstream media outlets. In a statement on Friday morning, Sanders claimed “we will also further develop rules and processes to ensure fair and orderly press conferences in the future. There must be decorum at the White House.”

Though CNN had been publicly defiant throughout the ordeal, behind the scenes last week the network tried to make peace with the Trump administration, The Daily Beast reported.

CNN higher-ups appealed to Trump press officials, and CNN head Jeff Zucker sent White House Chief of Staff John Kelly a letter requesting Acosta’s credentials be reinstated.

But CNN insiders said the administration was not receptive to the network’s attempts to restore Acosta’s credentials.

However, CNN did obtain one unlikely ally in their fight against the administration: Fox News. The right-wing cable outlet announced Wednesday they would file an amicus brief in support of CNN’s lawsuit, arguing that “Secret Service passes for working White House journalists should never be weaponized.”

In its support for CNN, Fox was joined by other major news outlets and companies like NBC News, the Associated Press, Bloomberg, First Look Media, Gannett, The New York Times, Politico, USA Today, and The Washington Post.