The White House said Tuesday it disagreed with a federal judge in Washington and ordered officials to reinstate Playboy journalist Brian Karem's credentials, which had been revoked following his altercation with former Trump aide Sebastian Gorka.

The ruling by U.S. District Judge Rudolph Contreras, a Barack Obama appointee, marked the second time a federal judge ordered the Trump administration to reinstate a reporter's pass. In November, a judge ordered CNN reporter Jim Acosta's credentials restored. The so-called hard pass allows reporters to easily obtain access to the White House grounds without having to separately apply for a press credential each time they seek entry.

"The First Amendment requires 'that individual newsmen not be arbitrarily excluded from sources of information,'" Contreras wrote in his opinion, citing federal case law. "His First Amendment interest depends on his ability to freely pursue 'journalistically productive conversations with White House officials.' Yet without his hard pass, he lacks access to pursue those conversations -- even as an eavesdropper."

In issuing a temporary restraining order and injunction against the White House, Contreras said that the White House's guidelines for appropriate behavior were insufficient and vague. Contreras' decision, although not yet a final ruling, signaled that he believed Karem ultimately would prevail.

CNN'S ACOSTA WINS BACK PRESS CREDENTIALS AFTER LAWSUIT

“White House events appear to vary greatly in character,” the judge wrote, adding that "without any contextual guideposts, ‘professionalism,’ standing alone, remains too murky to provide fair notice here. ... "Karem has provided some evidence that White House press events are often freewheeling and that aggressive conduct has long been tolerated without punishment."

The judge clarified that "In granting Karem relief, the Court finds only that the White House likely did not provide the requisite guidance in this specific case — nothing more. And, as noted earlier, the Court does not reach Karem’s independent free speech claim."

Nevertheless, the judge concluded: "Karem has shown that even the temporary suspension of his pass inflicts irreparable harm on his First Amendment rights."

Gorka and Karem got into a shouting match that was captured on video July 11, after Karem described the participants in a White House meeting of conservative social media personalities as a "group of people that are eager for demonic possession."

After a back and forth, Gorka shouted at Karem, "You are threatening me now in the White House, in the Rose Garden. You are threatening me in the Rose Garden. You're a punk, you're not a journalist, you're a punk."

Karem then told Gorka to "get a job." At one point, Karem suggested they take their conversation "outside."

The crowd erupted into chants of "Gorka! Gorka!" Karem replied that Gorka should "go home."

"No doubt, Karem’s remark that he and Gorka could 'go outside and have a long conversation,' was an allusion to a physical altercation, but the videos make clear that it was meant as an irreverent, caustic joke and not as a true threat,” the judge wrote on Tuesday.

Following Tuesday's ruling, White House press secretary Stephanie Grisham said the White House to be able to deter unprofessional behavior on the grounds of the Executive Mansion.

“We disagree with the decision of the district court to issue an injunction that essentially gives free rein to members of the press to engage in unprofessional, disruptive conduct at the White House," Grisham said. "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."

White House Correspondents' Association (WHCA) President Jonathan Karl, ABC News' chief White House correspondent, said: "The WHCA is gratified the U.S. District Court of the District of Columbia acted to uphold the due process rights of one of our members. The WHCA will continue to advocate for the rights of our members and against actions by the government that would have a chilling effect on journalism protected by the First Amendment. As we have said repeatedly, we believe everyone should conduct themselves professionally at the White House."

Immediately after the episode, Grisham had condemned Karem for "insulting invited guests," threatening a physical altercation and not leaving when a White House staffer asked him to do so during the event.

But the White House did not suspend Karem's hard pass until several weeks after the episode, after providing him notice and an opportunity to object. During that period, Karem was allowed onto the White House grounds -- providing evidence, the judge said, that the White House could afford to wait to enforce its sanction against Karem until after proceedings in the case were concluded.

Karem, meanwhile, was celebratory, tweeting, "Free Speech and Due process win!"

CLICK HERE TO GET THE FOX NEWS APP

Following that episode, the White House instituted new behavioral guidelines for White House guests requiring "professionalism," but Judge Contreras ruled that they were unclear.

“Though 'professionalism' has a well-known common meaning, it is inherently subjective and context dependent,” the judge wrote.

Fox News' Kelliane Jones, Brie Stimson and Meghan Welsh contributed to this report.