BEIJING — China reacted furiously to President Donald Trump’s signing of two bills on Hong Kong human rights, summoning the U.S. ambassador to strongly protest and warning the move would undermine cooperation with Washington.

Hong Kong, a former British colony that was granted special autonomy when China took control in 1997, has been rocked by six months of sometimes violent pro-democracy demonstrations.

Trump’s approval of the bill was not unexpected. Neither was the reaction from Beijing, given China’s adamant rejections of any commentary on what it considers an internal issue. But the clash comes at a sensitive time and could upset already thorny trade negotiations.

Chinese Vice Foreign Minister Le Yucheng told Ambassador Terry Branstad that the move constituted “serious interference in China’s internal affairs and a serious violation of international law,” a foreign ministry statement said.

Le called it a “nakedly hegemonic act.” He urged the U.S. not to implement the bills to prevent greater damage to U.S.-China relations, the ministry said.

In a statement about the meeting, the U.S. Embassy in Beijing said, “the Chinese Communist Party must honor its promises to the Hong Kong people.”

The U.S. “believes that Hong Kong’s autonomy, its adherence to the rule of law, and its commitment to protecting civil liberties are key to preserving its special status under U.S. law,” it said.

Since the Hong Kong protests began in June, Beijing has responded to expressions of support for the demonstrators from the U.S. and other countries by accusing them of orchestrating the unrest to contain China’s development. The central government has blamed foreign “black hands” bent on destroying the city.

C.Y. Leung, a former chief executive of Hong Kong, said at a talk at the Foreign Correspondents Club of Hong Kong that he doubts the U.S. or supporters of the bills in Hong Kong “ever had the interest of Hong Kong in mind.”

He suggested Hong Kong was a “proxy” for China for the U.S. in hitting back against Beijing.

While China has repeatedly threatened unspecified “countermeasures,” it’s unclear exactly how it will respond. Speaking on Fox News, Trump called the protests a “complicating factor” in trade negotiations with Beijing.

A foreign ministry statement Thursday repeated heated condemnations of the laws and said China will counteract. It said all the people of Hong Kong and China oppose the move.

Asked Thursday if the U.S. legislation would affect trade talks with Washington, a Chinese Commerce Ministry spokesman said he had no new information to share.

Recently both sides expressed confidence they were making headway on a preliminary agreement to avert a further escalation in a tariff war that has hammered manufacturers in both nations.

Trump signed the bills, which were approved by near unanimous consent in the House and Senate, even as he expressed some concerns about complicating the effort to work out a trade deal with China’s President Xi Jinping.

“I signed these bills out of respect for President Xi, China, and the people of Hong Kong,” Trump said in a statement. “They are being enacted in the hope that Leaders and Representatives of China and Hong Kong will be able to amicably settle their differences leading to long term peace and prosperity for all.”

Congress approved the bills last week following months of unrest in the semi-autonomous Chinese city. Before Wednesday’s signing announcement, Trump would only commit to giving the measures a “hard look.”

China’s foreign ministry called the laws a “naked hegemonic action” that seriously interfered in Hong Kong and China’s internal affairs, violated international law and “fundamental norms of international relations.”

“The U.S. side ignored facts, turned black to white, and blatantly gave encouragement to violent criminals who smashed and burned, harmed innocent city residents, trampled on the rule of law and endangered social order,” the statement said.

The laws’ basic intent is to undermine Hong Kong’s prosperity and stability along with the “historical progress of the great rejuvenation of the Chinese nation.”

It called the measures “extremely evil in nature and dangerous in motive.”

“We advise the U.S. not to act incautiously, otherwise China will be required to counteract resolutely and all the consequences created by this will have to be borne by the U.S. side,” the statement said.

The two countries are currently locked in a trade war and have deep differences over China’s claims to the South China Sea and Taiwan, human rights issues and accusations of Chinese industrial espionage.

The first bill Trump signed mandates sanctions on Chinese and Hong Kong officials who carry out human rights abuses and requires an annual review of the favorable trade status that Washington grants Hong Kong.

Another bill prohibits export to Hong Kong police of certain nonlethal munitions, including tear gas, pepper spray, rubber bullets, water cannons, stun guns and tasers.

The munitions bill was passed unanimously, while Republican Rep. Thomas Massie of Kentucky was the sole House member to oppose the human rights bill.

Democratic and Republican lawmakers applauded the signing of the bills. Sen. Robert Menendez, D-N.J., said it “finally sends a clear and unequivocal message to the people of Hong Kong: We are with you.”

Sen. Jim Risch, an Idaho Republican and chairman of the Senate Foreign Relations Committee, said the bills are “an important step forward in holding the Chinese Communist Party accountable for its erosion of Hong Kong’s autonomy and its repression of fundamental human rights.”

Rep. Chris Smith, R-N.J., who sponsored the House human rights bill, said Xi “should understand that the U.S. is not kidding about human rights. Beating, torturing and jailing of democracy activists is wrong and this historic legislation lets China know that respecting fundamental human rights is paramount.”

Activists hailed Trump’s action.

“I know that many people in Hong Kong are happy that the U.S. government has passed a new bill,” said Figo Chan, a 23-year-old Hong Kong protester who was honored with the John McCain Prize for Leadership at the Halifax International Security Forum in Canada last weekend.

“No one wants to die and no one wants to be hurt,” Chan said. “I hope that citizens of many different countries can in their own way fight for democracy.”