China has ordered the United States to close its consulate in the south-western city of Chengdu in retaliation for the American government forcing China to leave its mission in Houston earlier this week.

“The measure taken by China is a legitimate and necessary response to the unjustified act by the US,” the Chinese Foreign Ministry said in a statement on Friday. “It conforms with international law, the basic norms of international relations, and customary diplomatic practices.”

On Tuesday, the Trump administration ordered China’s consulate in Houston, Texas to close within 72 hours. It alleged Chinese agents tried to steal data from facilities including the Texas A&M medical system. China dismissed the allegation as “malicious slander”.

The tit-for-tat closures are one of the biggest threats in years to the increasingly fraught relationship between the US and China, which has worsened in recent months on fronts ranging from trade to the early handling of the coronavirus pandemic. The Chinese Foreign Ministry said it made specific requirements on the ceasing of all operations and events by the consulate.

“The current situation in China-US relations is not what China desires to see, and the US is responsible for all this,” the foreign ministry said. “We once again urge the US to immediately retract its wrong decision and create necessary conditions for bringing the bilateral relationship back on track.”

President Donald Trump said on Thursday that the US trade accord with China – one of the few things holding bilateral ties together – means “much less to me” because of what he called that country’s role in the spread of the coronavirus. Earlier, Chinese Foreign Ministry spokesman Wang Wenbin warned the US to think “carefully” about where the relationship was heading in response to a question about the future of the deal.

US officials have recently stepped up accusations of technology theft by China. In a speech Thursday, Secretary of State Mike Pompeo said some Chinese students and others “come here to steal our intellectual property and to take this back to their country”.

Also on Thursday, the US Justice Department said it believed the Chinese Consulate in San Francisco was harbouring a Chinese researcher, Tang Juan, who is accused of lying about her background in the Communist Party’s military wing on a visa application.

The department announced criminal charges of visa fraud against Ms Tang and three other Chinese researchers.

Authorities this week announced criminal charges against two Chinese computer hackers who are accused of targeting companies that are working on vaccines for the coronavirus.

The US mission in Chengdu, which opened in 1985, covers Sichuan, Yunnan, Guizhou and Chongqing in the country’s south-west. The consulate also serves as a key US listening post for developments in Tibet, where Communist Party efforts to suppress dissent has long been a focus of tensions between China and the West.

In 2012, then-Chongqing police chief Wang Lijun sought refuge in the Chengdu consulate with evidence linking the family of his then boss, former Chongqing party secretary Bo Xilai, to the death of a British businessman. The episode exposed a scandal that would see Bo ousted and his wife convicted of murder, and launched a nationwide anti-corruption campaign.