China passed legislation to retaliate against foreign sanctions, state-run media reported Thursday, as the country's tensions with the United States and other democratic nations have been escalating over human rights and security issues.

The move comes as the leaders of the Group of Seven countries, including the United States, France and Japan, are scheduled to gather in Britain later this week and are expected to discuss how to tackle China's growing security and economic assertiveness.

By enforcing the law, China will provide a legal basis for its decision to take countermeasures against sanctions imposed by other nations, which could trigger a further deterioration between Beijing and the United States, as well as its security allies, pundits say.

In retaliation, Beijing would take steps such as freezing assets held domestically by citizens of countries levying sanctions on China, and prohibiting them from entering the Asian nation, according to the full text of the law.

The legislation is needed to "resolutely safeguard the country's sovereignty, dignity and core interests, and to oppose Western hegemonism and power politics," Chinese Foreign Ministry spokesman Wang Wenbin told reporters.

When asked whether the law will negatively affect China's relations with other nations, Wang said, "This kind of worry is completely unnecessary."

The latest legislation was enacted at the Standing Committee of the National People's Congress, China's top legislative body, the official Xinhua News Agency said. It took effect on Thursday, after only one month of debate on the bill.

The Chinese Communist-led government has recently been at loggerheads with other countries over its alleged human rights abuses against the Muslim Uyghur minority in Xinjiang and security challenges posed to Taiwan and its vicinity.

Along with the United States, Britain and Canada, the European Union levied coordinated sanctions against the Asian nation over the Xinjiang issue earlier this year.

The administration of former U.S. President Donald Trump also imposed sanctions on China over intellectual property infringement, security threats from state-of-the-art technology and the crackdown on Hong Kong.

Xinhua said earlier this week that some countries have levied sanctions "in accordance with their domestic laws, grossly interfering in China's internal affairs."

The Global Times, a tabloid affiliated with the ruling Communist Party, said, "Some Western governments, out of political need and ideological prejudice, have been using Xinjiang-related topics and other excuses to spread rumors and suppress China."

This "particularly violates international laws and basic norms of the international relationship," the newspaper said.

At a four-day session of the standing committee through Thursday, a law, which would allow Chinese authorities to restrict data access on the grounds of national security, was also enacted.

The legislation will come into force on Sept. 1, sparking concern that Beijing would strengthen surveillance on companies by bolstering its control over data obtained and processed by them. The law will target not only Chinese firms but foreign enterprises.

Related coverage:

China, U.S. hold 3rd economic talks in 2 weeks over phone

Pentagon issues directive to revitalize alliances to counter China