New York (CNN Business) A federal judge ruled against the White House on Tuesday and ordered President Trump and press secretary Stephanie Grisham to immediately restore the press credentials of Brian Karem, a Playboy columnist and CNN political analyst.

"Karem has shown that even the temporary suspension of his pass inflicts irreparable harm on his First Amendment rights," US District Court Judge Rudolph Contreras wrote in his opinion.

Reacting to the decision, Karem told CNN, "It's good for me, but it's great for the free press. Today was about all of us."

Karem's attorney, Ted Boutrous, added in a statement to CNN that he was "very pleased" with the court's decision.

"The White House's suspension of his press credentials violated the First Amendment and due process and was a blatant attempt to chill vigorous reporting about the President," Boutrous said.

Karem's battle with the White House started on August 2 when Grisham notified him that she had made a "preliminary decision" to suspend his hard pass over a confrontation he had in the Rose Garden with Sebastian Gorka, a former White House aide and conservative media personality.

A hard pass is the credential that gives journalists access to the White House grounds.

Karem was given the opportunity to appeal Grisham's decision, which he did. But Grisham said in a letter dated August 16 that she had "made a final determination" to follow through with a 30 day suspension, revoking his access to the White House until September 14.

In the letter, made public by Karem's attorney, Grisham described Karem's behavior during the Rose Garden confrontation with Sebastian Gorka as inappropriate.

"Mr. Karem's conduct, taken as a whole, was unacceptable and disruptive, and requires a response to ensure that it does not happen again," Grisham wrote.

Grisham said she "carefully considered a range of potential responses," including "permanently revoking his hard pass, providing a written warning, and taking no action."

Ultimately, Grisham said, she determined a "permanent revocation would be too great a punishment." But, she wrote, "Taking no action, on the other hand, would be insufficient."

Karem is the second reporter who has had his hard pass suspended by the Trump administration. Last year the White House without warning revoked the hard pass of Jim Acosta , CNN's chief White House correspondent.

CNN took the White House to court. A key argument was that the White House had violated Acosta's due process rights when it revoked his access without warning. CNN ultimately won its case and the White House restored Acosta's hard pass

Following the legal loss to Acosta, the White House set up a system which allowed for — or at least provided the appearance of — some due process. As a result, Grisham first issued a "preliminary decision" against Karem and allowed him to appeal it.

Karem, however, rejected the notion he was afforded due process by the new system.

"It's a kangaroo court," Karem told CNN in August. "It's the exact opposite of due process. 'You're guilty, want to come in here and tell us why you're not?' No, that's not due process. That's the exact opposite of due process."

The judge presiding over his case agreed on Tuesday.

Contreras wrote in his opinion that Karem had "shown that he is likely to succeed" on his claim that his due process rights were violated when his pass was suspended.

"The present record indicates that Grisham failed to provide fair notice of the fact that a hard pass could be suspended under these circumstances," Contreras explained.

In a statement, Grisham said the White House "disagree[d] with the decision," arguing it "essentially gives free reign to members of the press to engage in unprofessional, disruptive conduct at the White House." She added that Karem "clearly breached well-understood norms of professional conduct."

"The press secretary must have the ability to deter such unacceptable conduct," Grisham said.

In his decision, Contreras sympathized with the White House's "desire to maintain a degree of control over access and decorum." But he said "the conferral of White House hard passes is no mere triviality" and "the need for regulatory guidance is at its highest where constitutional rights are implicated."

Contreras also dinged the White House for attempting to hold Karem to a vague standard of professionalism at the Rose Garden event.

"What is deemed 'professional' behavior in the context of a state dinner may be very different from what is considered 'professional' behavior during a performance by James Brown," the federal judge wrote.

The Justice Department could appeal the ruling. Or it could continue to press the lawsuit in Contreras' court, but that would be a steep uphill battle.

Asked if the Trump administration planned to continue its legal battle against Karem, Grisham declined to comment.