U.S. President Donald Trump on Wednesday signed into law congressional legislation backing protesters in Hong Kong despite angry objections from Beijing, with which he is seeking a deal to end a damaging trade war.

The new legislation, approved unanimously by the U.S. Senate and by all but one lawmaker in the House of Representatives last week, requires the State Department to certify, at least annually, that Hong Kong retains enough autonomy to justify favorable U.S. trading terms that have helped it maintain its position as a world financial center. It also threatens sanctions for human rights violations.

Congress passed a second bill — which Trump also signed — banning the export to the Hong Kong police of crowd-control munitions, such as teargas, pepper spray, rubber bullets and stun guns.

“I signed these bills out of respect for President Xi, China, and the people of Hong Kong. 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,” Trump said in a statement.

Trump had been vague about whether he would sign or veto the legislation, while trying strike a deal with China on trade that he has made a top priority ahead of his 2020 re-election bid.

China has denounced the legislation as gross interference in its affairs and a violation of international law.