The White House must return CNN reporter Jim Acosta’s permanent pass to him, a federal judge has ruled, after it was revoked in the wake of a clash with Donald Trump at a press conference.

Judge Timothy J Kelly, an appointee of President Trump, granted the motion to return the pass on Friday after hearing nearly two hours of arguments in the case earlier in the week. It is a temporary measure while the case CNN and Mr Acosta have brought against the White House is heard.

Standing outside the Washington DC courthouse, CNN lawyer Ted Boutrous described the ruling as a victory for the American press and freedom of speech.

“We’re extremely pleased with the ruling today. This is a great day for the first amendment and for journalism”, Mr Boutrous said.

Mr Acosta, appearing pleased, said he was grateful for the support he received following the revocation of his credentials. After the pass was revoked, news organisations unified in condemning the Trump administration’s decision, including Fox News, which is rarely critical of Mr Trump’s presidency.

“I want to thank all of my colleagues in the press who supported me this week,” Mr Acosta said outside the courthouse, before thanking the judge for the ruling. “Let’s get back to work.”

White House press person attempts to take microphone away from Jim Acosta as he asks Donald Trump question

Mr Acosta’s permanent press pass, known as a “hard pass”, was taken from the journalist after the White House accused him of “placing his hand on a young” intern during a press conference with the president soon after the 2018 midterm elections last week.

A video of the incident, which was broadcast live on national television in the US, shows Mr Acosta challenging the president over misleading claims he made in the weeks before the midterms that a migrant caravan travelling from Central America amounted to an invasion of the US, even though the thousands of asylum seekers and migrants at that point were hundreds of miles away from the US-Mexico border. Mr Acosta then attempted to ask about the Russia investigation.

During that exchange, the president told Mr Acosta to give up his microphone, and a White House intern approached and attempted to grab the microphone. Mr Acosta kept his grip on the device – saying “excuse me, ma’am” at one point to the intern – before eventually letting go of the microphone.

Mr Acosta and CNN have sued the Trump administration over the credentials, citing alleged violations of Mr Acosta’s first and fifth amendment rights. The first amendment guarantees the right to free speech and the press, while the fifth amendment guarantees the right to due process under the law.

Judge Kelly did not address the first amendment but instead focused on the fifth amendment.

“Whatever process occurred within the government is still so shrouded in mystery that the government at oral argument could not tell me who made the initial decision to revoke Mr Acosta’s press pass,” Mr Kelly said in his verbal ruling.

In court, Justice Department lawyers argued there is no first amendment right of access to the White House and that Mr Acosta was penalised for acting rudely at the conference and not for his criticisms of the president. The judge said White House press secretary Sarah Huckabee Sanders’ initial statement that Mr Acosta was rebuked for touching a White House staffer attempting to remove his microphone was “likely untrue and at least partly based on evidence that was of questionable accuracy”.

Support free-thinking journalism and attend Independent events

Responding to the ruling from the Oval Office, Mr Trump said that “people have to behave” and that he has told staff to “just leave” if reporters’ behaviour gets too much for them.

He also repeated an earlier statement from Ms Sanders which said new rules will be developed for press conferences and that there must be “decorum”.

“Today, the court made clear that there is no absolute first amendment right to access the White House,” Ms Sanders said. “In response to the court, we will temporarily reinstate the reporter’s hard pass. We will also further develop rules and processes to ensure fair and orderly press conferences in the future,” Ms Sanders said. “There must be decorum at the White House.”

“We are gratified with this result and we look forward to a full resolution in the coming days,” CNN said in a statement after the ruling. ”Our sincere thanks to all who have supported not just CNN, but a free, strong and independent American press.”