HONG KONG (AP) — Hong Kong police used tear gas Sunday and warned of further measures as they tried to clear thousands of pro-democracy protesters gathered at government headquarters in a challenge to Beijing over its decision to restrict democratic reforms for the semiautonomous city.

After spending hours holding the protesters at bay, police lobbed canisters of tear gas into the crowd on Sunday evening. The searing fumes sent demonstrators fleeing down the road, but many came right back to continue their protest.

The protesters were trying to join a sit-in outside government headquarters calling for Beijing to grant genuine democratic reforms to the former British colony. The sit-in, however, became overshadowed by running confrontations on the surrounding streets between police and those who were blocked from entering the protest zone.

Students and activists have been camped out since late Friday on the streets outside the government complex, located just a few blocks from Hong Kong’s downtown financial district. Students started the rally, but leaders of the broader Occupy Central civil disobedience movement said early Sunday that they were joining them to kick-start a long-threatened mass sit-in to demand that an election for Hong Kong’s leader be held without Beijing’s interference.

Police used the tear gas after the protest spiraled into an extraordinary scene of chaos, with the demonstrators jamming a busy road and clashing with officers wielding pepper spray.

“It was very cruel for the police to use such harsh violence on protesters who had been completely peaceful,” said one of the demonstrators, Cecily Lui, a 30-year-old clerk. “They were just sitting down on the road asking to speak with (Hong Kong leader) Leung Chun-ying to start a dialogue. Now, police have solved nothing and students are more resolved to stay.”

After using the tear gas, police issued a statement urging the protesters to “leave peacefully and orderly.”

“Otherwise police will use a higher level of force in order to restore public order and safeguard public safety,” the statement warned.

The demonstrations — which Beijing called “illegal” — were a rare scene of disorder in the Asian financial hub, and highlighted authorities’ inability to rein in the public discontent over Beijing’s tightening grip on the city. The protesters reject Beijing’s decision last month to rule out open nominations for candidates under proposed guidelines for the first-ever elections for Hong Kong’s leader, promised for 2017.

China took control of Hong Kong from Britain in 1997, agreeing to a policy of “one country, two systems” that allowed the city to maintain a high degree of control over its own affairs and keep civil liberties unseen on the mainland, while promising that the city’s leader can eventually be chosen through “universal suffrage.” But Beijing’s insistence on using a committee to screen election candidates for patriotism to China — similar to the one that currently hand-picks Hong Kong’s leaders — has stoked fears among democracy groups that Hong Kong will never get genuine democracy.

Initial momentum for the protests came from university and college students, who had organized a weeklong boycott of classes that they now say will run until officials meet their demands, which include reform of Hong Kong’s legislature and withdrawing the proposal to screen the election candidates.

Organizers of the Occupy Central nonviolent civil disobedience movement, who had long threatened their own mass sit-in to paralyze the city’s financial district, announced after midnight Saturday that they would instead join the student demonstration.

Thousands of people who tried to join the sit-in on Sunday breached a police cordon, spilling out onto a busy highway and causing traffic to come to a standstill.

Police officers in a buffer zone manned barricades and doused the protesters with pepper spray carried in backpacks. The demonstrators, who at one point tried to rip apart metal barricades, carried umbrellas to deflect the pepper spray by the police, who were wearing helmets and respirators.

Police had told those involved in what they say is an illegal gathering to leave the scene as soon as possible, warning that otherwise they would begin to clear the area and make arrests.

After police used the tear gas, the protesters chanted “Shame on C.Y. Leung,” referring to the city’s deeply unpopular Beijing-backed leader. To many, it seemed to mark a major shift for Hong Kong, whose residents have long felt their city stood apart from mainland China thanks to its guaranteed civil liberties and separate legal and financial systems.

Hong Kong “has changed to a new era so the people have to be awakened. It’s no longer the old Hong Kong,” said one protester, W.T. Chung, 46, who yelled at police officers after they used the tear gas.

Earlier, police said they had arrested 78 people since demonstrations started late Friday. Among those arrested was 17-year-old Joshua Wong, who was dragged away by police soon after he led a group of students storming the government complex. Student protesters had demanded his release, but unlike most of those arrested, who were freed soon afterward, Wong remained in custody for about two days, until being released Sunday evening.

Police on Sunday took away several pro-democracy legislators who were among the demonstrators.

Leung said Hong Kong’s government was “resolute in opposing the unlawful occupation” of the government offices or the financial district by Occupy Central.

“The police are determined to handle the situation appropriately in accordance with the law,” he said at a news conference.

The Chinese government agency that handles Hong Kong affairs condemned the protests.

“China’s central government firmly opposes illegal acts taking place in Hong Kong,” and fully supports the local government in handling the matter according to the law, the official Xinhua News Agency quoted the Hong Kong and Macau Affairs Office of the State Council as saying.