A federal judge on Tuesday reversed the White House’s decision to suspend a reporter’s press credentials, granting a motion that will restore him to his beat.

The ruling was a victory for Brian Karem, a White House correspondent for Playboy magazine and a CNN political analyst, who had been suspended by officials for 30 days in mid-August because of his role in a verbal confrontation with a former White House aide at a White House event on July 11.

He was the second reporter suspended in the past nine months, a step that appears to be without recent precedent before President Trump’s administration. Trump banned more than a dozen news organizations, including The Washington Post, from his campaign events in 2015 and 2016 but said he wouldn’t do so if he became president.

Karem, who has been outspoken in his opposition to Trump, sued White House press secretary Stephanie Grisham and the president last month. He argued that the suspension, which began Aug. 16, was arbitrary and violated his constitutional rights of free speech and due process.

Grisham, however, cast the action as a matter of decorum, saying Karem’s behavior was disruptive and warranted the punishment.

U.S. District Judge Rudolph Contreras agreed with Karem on Tuesday. He issued a preliminary injunction against the White House’s action, ruling that Karem had shown that he is “likely to succeed” on his due process claim because Grisham “had failed to provide fair notice of the fact that a hard pass could be suspended” as a result of his actions on July 11. He ordered the White House to restore the hard pass — a credential that enables journalists to come and go on a daily basis — while his lawsuit proceeds.

“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 judge said.

Karem, in an interview Tuesday night, said the ruling “is good for me, but it’s really for everyone in the free press. [The judge] didn’t buy anything the White House was selling. . . . As much as this president has tried to bully us, we’re not going away. As much as he’s called us the enemy of the people, the Constitution is clear about what free speech is all about.”

In a statement, Grisham said: “We disagree with the decision of the district court to issue an injunction that essentially gives free reign to members of the press to engage in unprofessional, disruptive conduct at the White House. Mr. Karem’s conduct, including threatening to escalate a verbal confrontation into a physical one to the point that a Secret Service agent intervened, clearly breached well-understood norms of professional conduct. The press secretary must have the ability to deter such unacceptable conduct.”

She declined to comment on any further action against Karem.

Contreras’s decision was the second judicial ruling to go against the White House in its attempts to punish reporters for what it has deemed misconduct. Karem’s lawsuit over the loss of his pass followed a similar suit last fall by Jim Acosta of CNN. Acosta was suspended on an indefinite basis by the White House after engaging in a heated exchange with Trump at a news conference. A federal judge quickly sided with Acosta, ruling that the White House had overstepped its authority. His pass was restored.

Both reporters were represented by the same lawyer, Theodore Boutrous Jr., and both made similar arguments in their lawsuits: that Trump was essentially seeking to punish the press in violation of the First Amendment and had done so without any notice or established procedure in violation of the Fifth and 14th amendments’ guarantee of due process. In a response to Grisham, Boutrous argued last month that the White House’s actions were “arbitrary and unfair.”

On Tuesday, Boutrous said: “We are very pleased with the court’s order directing the restoration of Brian Karem’s hard pass. 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.”

Lawyers for the Justice Department argued in court last week that the White House took appropriate steps before booting Karem, such as notifying him that he was facing suspension and giving him a day to respond.

Grisham notified Karem last month that he would be suspended as a result of his exchange in July with Sebastian Gorka, a former White House aide who is a talk-radio host.

The incident — recorded by multiple witnesses — followed remarks by Trump in the Rose Garden after a “summit” of the president’s social-media supporters. When Karem asked Trump whether he would take questions and received no answer, he was taunted by some in the audience. He retorted that its members were “eager for demonic possession.” He said later the comment was meant in jest.

Gorka then jumped in, shouting across the audience at Karem, who invited Gorka to “go outside and have a long conversation.” Although Karem later said he meant that comment in earnest, Gorka took it as an offer to fight and stormed across the grounds to confront Karem.

He called Karem “a punk.”

Trump later praised Gorka, tweeting “@SebGorka Wins Big, No Contest!

Karem’s case drew support from journalism organizations and free-speech advocates, who said the White House was acting in an authoritarian manner.