China on Friday ordered the closure of the U.S. consulate in the western city of Chengdu in Sichuan Province, apparent retaliation for the Trump administration closing China’s Houston consulate over accusations of espionage.

“The measure taken by China is a legitimate and necessary response to the unjustified act by the United States,” the foreign ministry said in a statement.

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

The Trump administration says Chinese agents within the Texas consulate had been attempting to steal scientific data from facilities in the state, including the Texas A&M medical system.

After the order to close the Houston consulate, a State Department spokesperson said the U.S. "will not tolerate the PRC’s violations of our sovereignty and intimidation of our people, just as we have not tolerated the PRC’s unfair trade practices, theft of American jobs, and other egregious behavior. President Trump insists on fairness and reciprocity in U.S.-China relations."

The Chinese Embassy in Washington said in a statement: “The U.S. accusations are groundless fabrications,” according to The New York Times.

Beijing on Wednesday promised to retaliate over the order to close its Houston consulate by the end of the week, calling the decision an “unprecedented escalation.”

CHINA THREATENS RETALIATION AFTER US ORDERS CLOSURE OF HOUSTON CONSULATE 

“China demands the U.S. revoke the wrong decision. If the U.S. went ahead, China would take necessary countermeasures,” Chinese foreign ministry spokesman Wang Wenbin said.

Foreign Ministry spokesperson Wang Wenbin gestures for questions during a daily briefing in Beijing Thursday, July 23, 2020. China ordered the United States on Friday, July 24, 2020 to close its consulate in the western city of Chengdu, ratcheting up a diplomatic conflict at a time when relations have sunk to their lowest level in decades. (AP Photo/Ng Han Guan)

The consulate closures and spying accusations come amid heightened tensions between the two countries over trade, the coronavirus and Hong Kong.

The Trump administration has also put restrictions on visas for some Chinese journalists and canceled visas for Chinese graduate students with ties to military schools. China also expelled U.S. journalists from three major newspapers earlier this year, according to The Times.

CHENGDU, CHINA - JULY 23: People walk by the US Consulate-General in Chengdu on July 23, 2020 in Chengdu, Sichuan Province of China. (Photo by VCG via Getty Images)

Just hours before China ordered the closure, U.S. Secretary of State Mike Pompeo said in a speech, “If we want to have a free 21st century and not the Chinese century of which Xi Jinping dreams, the old paradigm of blind engagement with China simply won’t get it done,” The Times reported.

CLICK HERE TO GET THE FOX NEWS APP

The U.S. Justice Department Thursday said it believes a Chinese researcher at the University of California, Davis, accused of hiding her ties to the military is taking refuge in the Chinese consulate in San Francisco.

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

U.S. 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.

CLICK HERE TO GET THE FOX NEWS APP

The United States has an embassy in Beijing and consulates in five other mainland cities — Shanghai, Guangzhou, Chengdu, Shenyang and Wuhan. It also has a consulate in Hong Kong, a Chinese territory.

The Associated Press contributed to this report.