BEIJING - China passed a law on Thursday to counter foreign sanctions, as it strives to resist U.S. and EU pressure over trade, technology, Hong Kong and Xinjiang.

Individuals or entities involved in making or implementing discriminatory measures against Chinese citizens or entities could be put on an anti-sanctions list by a "relevant department" in the Chinese government.

Those on the list may be denied entry into China or be expelled from China. Their assets within China may be seized or frozen. They could be restricted from doing business with entities or people within China.

The new law is China's latest and most wide-ranging legal tool to retaliate against foreign sanctions and is intended to give Chinese retaliatory measures more legitimacy and predictability, according to local experts.

Foreign companies, however, worry about the dampening impact it might have on foreign investment.

China's top legislature, the National People's Congress (NPC) standing committee passed the law on Thursday, according to state television CCTV.

All 14 vice-chairpersons of the committee are under U.S. sanctions for passing the National Security Law last year that critics say has crippled political freedoms in Hong Kong. Beijing says it was needed to restore stability in the city.

President Xi Jinping called last November for the ruling Communist Party to use legal means to defend China's sovereignty, security and interests against foreign parties.

The NPC said in its annual work report in March that it wants to "upgrade our legal toolbox" to address the risks from foreign sanctions and interference. 

In January, the commerce ministry announced mechanisms to assess if foreign restrictions on Chinese trade and business activities were justified, and for Chinese individuals or companies to sue for compensation in a Chinese court. 

The United States and its allies have increasingly sanctioned Chinese officials to express concern about how China treats its Muslim Uyghur minority in Xinjiang and pro-democracy activities in Hong Kong, triggering counter-sanctions by China on U.S. and EU policitians and officials.

Washington has also targeted Chinese companies such as Huawei and ZTE for violating U.S. sanctions on Iran or North Korea, an act China called "long-arm jurisdiction".

The bill underwent a secret first reading in April, and was passed on Thursday, barely two days after NPC announced that it was doing a second reading of the bill. It skipped a third reading normally needed for other bills.

The European Union Chamber of Commerce said its members are alarmed at the lack of transparency about the passing of the bill.

"China seems to be in a hurry. Such action is not conducive to attracting foreign investment or reassuring companies that increasingly feel that they will be used as sacrificial pawns in a game of political chess," Joerg Wuttke, the Chamber's president, told Reuters.

Foreign companies looking to do business in China may find themselves up against increasing scrutiny from Chinese regulatory authorities in relation to their operations both locally and abroad, said Shaun Wu, a partner at law firm Paul Hastings.

Chinese experts say Beijing is simply taking a page from the playbooks of the United States and European Union, which in recent years have passed various acts to serve as a legal basis for their engagement with China.

"China previously had neither the economic power nor the political will to use legal means to retaliate against U.S. sanctions. It now has both," said Wang Jiangyu, a law professor at City University of Hong Kong.

"Cooperation is the best option but the U.S. doesn't want it. So retaliation, such as with this new law, is the second best option. Sucking it up is the worst," he said.

(Reporting by Yew Lun Tian; Additional reporting by Alun John in Hong Kong; Editing by Kim Coghill and Toby Chopra) ((LunTian.Yew@thomsonreuters.com;))