Hong Kong's legislature passed a controversial immigration bill that lawyers, diplomats, and human rights groups fear would grant unrestricted authority to bar residents and others from entering or leaving the Chinese-ruled city.

The government has dismissed those concerns as "complete nonsense," claiming that the legislation passed Wednesday, which goes into effect on Aug. 1, simply seeks to screen illegal immigrants to reduce the backlog of asylum applications and has no impact on constitutional rights to free movement.

"We are facing increasing challenges, especially preventing the number of illegal immigrants from rising and claimants from abusing the system," Security Secretary John Lee said.

The assurances, however, come amid a climate of distrust following the increasingly authoritarian direction officials have taken, culminating in Beijing's imposition of a sweeping national security law last year.

According to lawyers, the new law empowers authorities to prohibit anyone from entering or leaving Hong Kong without a court order, effectively opening the door to mainland China-style exit bans, and fails to avoid indefinite detention of refugees.

According to the Hong Kong Bar Association (HKBA), the bill failed to clarify why such powers were needed, how they would be used, and offered no cap on the length of any travel ban, as well as any protections against abuse.

The Security Bureau stated that the law would only apply to inbound flights and would target illegal immigrants, expressing dissatisfaction at HKBA's "unnecessary misunderstanding."

Nonetheless, lawyers, diplomats, trade unions, and business organizations were perplexed by the government's refusal to include the specified restrictions in the bill.

Last year, a group of U.S. senators reported that at least two dozen U.S. citizens had been barred from leaving China in recent years and were subjected to constant surveillance and abuse by authorities. China denies that foreign nationals face illegal detention or exit bans.

The bill also states that authorities may detain a refugee if "the person poses, or is likely to pose, a threat or security risk to the community," and it does not specify what that risk is. According to rights groups, it expands the scope of indefinite detention.

The immigration bill received 39 votes in favor and two votes against. It was passed shortly after lawmakers approved a budget in record time, with just one dissenting vote.