A pilot, a nurse and several teenage students were among 40 people who appeared in a Hong Kong courtroom on Wednesday facing up to 10 years in jail on rioting charges over their role in mass protests that have convulsed the city since June.

Anger at the potential heavy sentences brought hundreds of demonstrators to the courtroom doors in support of the group inside, chanting “revolution of our time” and “liberate Hong Kong”.

Rights groups warned that the riot charge and heavy-handed policing showed a “flagrant disregard” of city residents’ rights and appeared aimed mostly at stifling dissent, as authorities grapple with the worst political crisis since the handover from British rule in 1997.

The threat of rioting charges has been a source of anger since the protest movement began in early June, but this is the first time they have been deployed against demonstrators.

“By using such vague charges against pro-democracy protesters, the Hong Kong authorities seem intent on sending a chilling warning to anyone considering taking part in future protests,” Amnesty International said in a statement.

Hong Kong law defines rioting as the unlawful assembly of three or more people, where any person “commits a breach of the peace”.

Protesters outside the Eastern magistrates court in Hong Kong. Photograph: Billy HC Kwok/Getty Images

The arrests were made over peaceful protests at the weekend that turned violent, with police unleashing teargas and rubber bullets against demonstrators who hurled umbrellas, rocks, eggs and gas canisters back at officers.

“While there was violence over the weekend, the definitions of illegal assembly and rioting under Hong Kong law are so broad they fall far short of international standards,” Amnesty said. “It is highly questionable that individuals facing these sweeping charges would have a fair chance of defending themselves at trial.”

In a sign of how broad-based support for the protests has been, the people arrested ranged from a pilot with the city’s flagship airline Cathy Pacific, to a chef, an electrician and a construction worker, according to local news reports. The youngest is 16, the oldest 41.

Quick Guide What are the Hong Kong protests about? Show Why are people protesting? The protests were triggered by a controversial bill that would have allowed extraditions to mainland China, where the Communist party controls the courts, but have since evolved into a broader pro-democracy movement. Public anger – fuelled by the aggressive tactics used by the police against demonstrators – has collided with years of frustration over worsening inequality and the cost of living in one of the world's most expensive, densely populated cities. The protest movement was given fresh impetus on 21 July when gangs of men attacked protesters and commuters at a mass transit station – while authorities seemingly did little to intervene. Underlying the movement is a push for full democracy in the city, whose leader is chosen by a committee dominated by a pro-Beijing establishment rather than by direct elections.

Protesters have vowed to keep their movement going until their core demands are met, such as the resignation of the city’s leader, Carrie Lam, an independent inquiry into police tactics, an amnesty for those arrested and a permanent withdrawal of the bill. Lam announced on 4 September that she was withdrawing the bill. Why were people so angry about the extradition bill? Beijing’s influence over Hong Kong has grown in recent years, as activists have been jailed and pro-democracy lawmakers disqualified from running or holding office. Independent booksellers have disappeared from the city, before reappearing in mainland China facing charges. Under the terms of the agreement by which the former British colony was returned to Chinese control in 1997, the semi-autonomous region was meant to maintain a “high degree of autonomy” through an independent judiciary, a free press and an open market economy, a framework known as “one country, two systems”. The extradition bill was seen as an attempt to undermine this and to give Beijing the ability to try pro-democracy activists under the judicial system of the mainland. How have the authorities responded? Beijing has issued increasingly shrill condemnations but has left it to the city's semi-autonomous government to deal with the situation. Meanwhile police have violently clashed directly with protesters, repeatedly firing teargas and rubber bullets. Beijing has ramped up its accusations that foreign countries are “fanning the fire” of unrest in the city. China’s top diplomat Yang Jiechi has ordered the US to “immediately stop interfering in Hong Kong affairs in any form”. Lily Kuo and Verna Yu in Hong Kong

Most were released on bail of around HK$1000 (£104), with a curfew from midnight to 6am, and many ordered to stay in Hong Kong.

Protests were originally spurred by concerns over a now-shelved extradition law, that would have effectively removed the legal firewall between Hong Kong and China. But they have expanded to cover fury at police brutality, and wider questions about the future of Hong Kong as an autonomous city within an ever-more assertive China.

And while the riot charges and the prospect of long sentences may have alarmed some would-be protesters, for others it has just increased their fury.

“I’m not scared to protest. This whole thing today is just making me more angry,” said Gartner, a 21-year-old protester outside the court who declined to give his full name.

The arrests had already spurred fresh unrest on Tuesday evening, as hundreds of protesters gathered at police stations where the group was being held, and faced riot police who deployed pepper spray and batons to try and disperse the crowd.

A police officer points a shotgun at protesters in Hong Kong. Photograph: Tyrone Siu/Reuters

Photos of a policeman pointing a shotgun at protesters near Kwai Chung police station circulated rapidly, spurring outrage. Police said the weapon was loaded only with non-lethal bean bags, and was being used because the officer felt under threat.

In one video circulated on social media, a police officer was seen punching a photographer, then wildly waving a baton at a journalist, who was wearing a yellow vest and who was forced to flee.

Outside Tin Shui Wai station, it the early hours of Wednesday morning, a private car drove by and let off fireworks towards the crowd, injuring six. There were no immediate arrests although police said they strongly condemned the attack.

Adding to the sense of crisis in Hong Kong as the position of authorities and protesters appeared to harden, a senior official from Donald Trump’s administration said on Wednesday that the United States was monitoring what appeared to be a buildup of Chinese forces on the border, Bloomberg news agency reported.

The exact nature of the military buildup was unclear, the unnamed official said, but armed police or military appeared to be gathering just outside Hong Kong territory.

China warned on Monday, in a rare direct intervention, that violent protesters should be swiftly punished. Despite peaceful protests drawing a reported 2 million people, a government official blamed the unrest on a “few radicals”.

“No civilised society or rule of law society will tolerate rampant violence,” said Yang Guang, a spokesman for the office which handles Hong Kong and Macau events for Beijing. It was the first time the office has given a press conference since the 1997 handover from colonial rule.

“In our view, the most dangerous situation in Hong Kong is that violent crimes have not been effectively stopped,” he added.