BEIJING — China’s legislature approved an antiterrorism law on Sunday after months of international controversy, including criticism from human rights groups, business lobbies and President Obama.

Critics had said that the draft version of the law used a recklessly broad definition of terrorism, gave the government new censorship powers and authorized state access to sensitive commercial data.

The government argued that the measures were needed to prevent terrorist attacks. Opponents countered that the new powers could be abused to monitor peaceful citizens and steal technological secrets.

In the end, the approved law published by state media dropped demands in the draft version that would have required Internet companies and other technology suppliers to hand over encryption codes and other sensitive data for official vetting before they went into use.