A US judge on Sunday blocked the government’s ban on WeChat downloads, hours before it was due to take effect in an ongoing technology and espionage battle between Washington and Beijing.

The Trump Administration had ordered a ban on downloads of the messaging platform WeChat as well as hugely popular video-sharing app TikTok, both owned by Chinese companies. Both bans have now been suspended.

A California court ruling said it granted a “motion for a nationwide injunction against the implementation” of the government order on WeChat, with the judge citing concerns over free speech.

The order would have slowed WeChat down and made it unusable in the US for video chats with family and friends, according to experts.

Owned by technology giant Tencent, WeChat has around 19 million active daily users in the US.

When contacted, Tencent declined to comment on the ruling.

The ruling “is a short-term relief for the plaintiffs, who wanted to be sure that the app was not shut down tonight”, said Carl Tobias, a law professor at the University of Richmond.

If the government appeals and wins, the plaintiffs can appeal that decision. “The plaintiffs wanted to just buy time,” Tobias said. “It may be very soon that the president is no longer the president.”

As President Donald Trump seeks a breakthrough with voters to win a second term in the November 3 election, he has increasingly put national security and his aggressive stance toward China at the centre of his campaign.

He regularly accuses Democratic opponent Joe Biden of weakness toward Beijing.

The president on Saturday said he had approved a deal allowing Silicon Valley giant Oracle to become data partner for TikTok to avert a shutdown of that app.

The deal, announced by the companies, includes Walmart as a commercial partner and would create a new US company named TikTok Global.