In a reflection of Beijing's assertion that the protests are part of a foreign conspiracy, the ministry said the legislation should unite Chinese, including those in Hong Kong, in opposition to "sinister" US intentions.
Hong Kong's government also denounced the US legislation as "unreasonable" meddling, saying it sends the wrong signal to protesters and won't help to ease the crisis.
It also threatens sanctions for human rights violations.
The US legislation follows a week of increased violence that spread to university campuses, culminating in a police siege of the Hong Kong Polytechnic University in the neighbourhood of Hung Hom.
President Trump on Wednesday signed the Hong Kong Human Rights and Democracy Act, which will seek to ensure that Hong Kong has sufficient autonomy from China to maintain favorable trading terms with the United States.
If Hong Kong becomes just another Chinese port, this could hurt not just the city and China, but USA businesses too, and companies that rely on the territory's role as a middleman, or for trans-shipping, would likely take their business elsewhere.
"Look, we have to stand with Hong Kong".
As the protests have advanced, protesters have settled around five key demands from the Hong Kong government.
Hong Kong police safety teams meanwhile began clearing a university that was a flash point for clashes with anti-government demonstrators, and an officer said any holdouts still hiding inside would not be immediately arrested.
It will also allow Hong Kong residents to apply for a United States visa - a document which allows people to leave, stay or enter there for a set amount of time - even if they have been arrested for taking part in non-violent protests.
"Traders are fearful that China will lash-out at the USA, which is why stocks are lower", he said.
But the move provoked fury from Beijing, which called it an "an act of undisguised hegemony".
China says it is committed to the "one country, two systems" formula put in place at the handover, and blames foreign forces for fomenting the unrest, an allegation it repeated in response to the U.S. law.
Trump on the same day approved another bill prohibiting the export of tear gas and certain other munitions to Hong Kong police. Some 1,100 protesters have left or have been arrested.
But police searching a university campus, which was the scene of fierce battles with protesters earlier this month, have found hundreds of home-made bombs.
The US law is seen as another win for the pro-democracy movement in the city, coming days after pan-democrats scored a landslide victory in the district elections.