SHANGHAI, Oct. 12 — China is planning to adopt a new law that seeks to crack down on sweatshops and protect workers’ rights by giving labor unions real power for the first time since it introduced market forces in the 1980’s.

The move, which underscores the government’s growing concern about the widening income gap and threats of social unrest, is setting off a battle with American and other foreign corporations that have lobbied against it by hinting that they may build fewer factories here.

The proposed rules are being considered after the Chinese Communist Party endorsed a new doctrine that will put greater emphasis on tackling the severe side effects of the country’s remarkable growth.

Whether the foreign corporations will follow through on their warnings is unclear because of the many advantages of being in China — even with restrictions and higher costs that may stem from the new law. It could go into effect as early as next May.