The rallies were the first significant public gatherings since the ban took effect the day before, and a test of the government’s resolve to stop months of protests.

Image

CreditCreditLam Yik Fei for The New York Times

HONG KONG — Defying a new ban on face masks, tens of thousands of people marched across Hong Kong on Sunday, a largely peaceful show of force against the government punctuated by the increasingly common clashes between protesters and police.

The two marches, both in the pouring rain, were the first significant public gatherings since the ban took effect early Saturday, stirring anger that the government was infringing on the civil freedoms that this semiautonomous territory has maintained since being returned to Chinese control more than two decades ago.

Outside the shuttered malls and stores of a major shopping district in downtown Hong Kong, demonstrators, many wearing blue, gray or black masks, chanted “Hong Kongers, resist!” Across the harbor, protesters also held a march that began in the Tsim Sha Tsui neighborhood of Kowloon.

By nightfall, protesters on the fringes of both marches were vandalizing subway stations and throwing bricks and firebombs, leading to standoffs with the police, who blanketed some neighborhoods with tear gas. As the prospect of pitched street battles loomed, the police force warned in an all-caps text message to residents that “unauthorized public events” would be likely to cause violence.

The large marches and the widespread defiance of the emergency proclamation were both a symbol of the staying power of the monthslong pro-democracy movement and a potential test of local officials’ resolve to stop the demonstrators’ momentum.

The persistent and increasingly violent protests have strained the local economy, putting pressure on the government to take action. They are also testing the patience of China’s Communist Party leaders, who have watched the Hong Kong protests warily for months and warned that using force against them is an option.

The city has been bracing for more unrest since the government announced on a ban on face mask, gear that has become ubiquitous in the movement. In doing so, Hong Kong’s embattled leader invoked a rarely used, colonial-era law that allows for new regulations when the territory faces “a state of serious danger.”

The announcement immediately unleashed violent protests across the city on Friday. Hong Kong was quieter on Saturday, as a shutdown of the entire subway system brought the city to a near standstill, although masked protesters openly flouted the ban at scattered gatherings.

“Maybe they’re trying a new model of dealing with the Hong Kong situation — of turning it into a de facto emergency state,” said Gary Fong, a lecturer at Hong Kong Community College who studies policing strategies.

From a tactical perspective, he added, the face mask ban will not help police officers much, mostly because the rule carries a maximum jail term of only one year — a tenth of what protesters already faced whenever they joined any of the many unauthorized marches.

And when it comes to punishing protesters, he added, police officers still face an obvious challenge: “You have to catch them.”

The protests began four months ago in opposition to a now-abandoned bill that would have allowed the extradition of criminal suspects to the Chinese mainland. They have since evolved into a broader call to protect the autonomy of Hong Kong.

The movement has intensified, with dozens of violent street clashes between demonstrators and police officers that have steadily grown more combative and dangerous.

On Tuesday, a protester was shot by the police for the first time. Another was shot on Friday, though the police did not claim responsibility. Both protesters were teenagers.

The Hong Kong authorities are “using the police force to solve political problems” and stifling public opinion in a way that leaves little daylight between Hong Kong and the mainland, said Ken Chan, a 21-year-old university student who joined the rally in Causeway Bay.

When the protests began in June, “our original motivation was based on the fear that Hong Kong will become like the mainland,” said Mr. Chan, who wore a gray mask to the rally. “So when they impose this ban, it will only set people off further.”

Although the marches on Sunday began peacefully, hard-core demonstrators on the fringes of the Hong Kong Island protest put a hose into the Wan Chai subway station, attempting to flood it.

And in Jordan on the Kowloon Peninsula, protesters smashed and spray-painted the entrance to a subway station, then lit a fire outside it. Others set roadblocks and broke into a grocery store whose owner they suspected of being from mainland China.

“The heavens will exterminate the CCP,” one protester wrote in graffiti, referring to the Chinese Communist Party.

After a day of eerie quiet on Saturday, the city and its subway system had partially returned to life by Sunday morning. But many stations and stores across the city were either still closed on Sunday afternoon or were scheduled to close early.

The face mask ban applies to public gatherings of more than a few dozen people and is punishable by a fine in addition to the one year in jail. But enforcing the ban is likely to prove difficult, not least because of their widespread use to guard against tear gas and protect demonstrators’ identities.

The ban draws on the so-called Emergency Regulations Ordinance, a colonial-era law that offers Hong Kong’s leader extensive legal authority to bypass the local legislature. It was last used during deadly pro-Communist riots in 1967 that targeted the British government that administered the city.

Hong Kong’s leader, Carrie Lam, delayed invoking the law for weeks, out of concern that it would hurt efforts to persuade residents, tourists and international businesses that the city is still a safe place. She appears to think the ban’s potential upside for the government — dissuading moderate Hong Kongers from joining demonstrations — is worth the damage it would inflict upon her reputation.

But Hong Kongers are also deeply sensitive to efforts to erode the civil liberties that have long differentiated their city from the rest of China and helped make it an attractive destination for international bankers and investors. And many here see the ban — like the contentious extradition legislation that triggered the protests — as something that could fundamentally change the city’s identity.

Mr. Chan, the protester in Causeway Bay, said he did not think the mask ban would significantly depress the turnout for rallies or marches in Hong Kong because protesters were already facing rioting charges that carry jail terms of up to 10 years just for showing up at rallies that the police deem unauthorized.

“But undoubtedly, those who are more fearful might not dare,” he added.

Even if moderate protesters stay home, the ban may still inflame hard-core demonstrators who have increasingly resorted to violence and widespread vandalism as a way of pressing the movement’s demands for government accountability and democratic reforms.

Jeannie Mok, a 19-year-old student who was protesting in Kowloon on Sunday, said that when Mrs. Lam promised in September to withdraw the extradition bill, many in the protest movement felt that their demonstrations had lost some legitimacy.

“But this emergency law has sparked everyone’s anger once again,” she said. “I see more people here today, angry and ready to do more damage. I don’t understand why the government would provoke when they want the protests to end.”

The face mask ban has already prompted stiff opposition from Mrs. Lam’s opponents in Hong Kong’s legislature.

On Saturday, 24 members of the city’s pro-democracy legislative minority asked a Hong Kong court to put the mask ban on hold. They accused Mrs. Lam of overstepping her legal authority under the Basic Law, the mini-constitution that has governed Hong Kong since Britain handed it back to Chinese control in 1997.

“Today is a battle between totalitarianism and the rule of law,” one of the lawmakers, Dennis Kwok, told reporters on Sunday morning. “So the government can implement any law they want — is that the way it is now? Or is Hong Kong still a society under the rule of law?”

Mrs. Lam has called Mr. Kwok’s argument “groundless.” And on Sunday — just before the Causeway Bay rally began — the city’s High Court threw out the request for an injunction against the ban.

Ezra Cheung, Katherine Li, Edward Wong, Andrew Jacobs and Austin Ramzy contributed reporting.