Anti-government protesters attacked the Hong Kong office of China's official Xinhua News Agency for the first time Saturday after chaos broke out downtown, with police firing tear gas and demonstrators hurling gasoline bombs as the protest movement approached the five-month mark.

Streets in the upscale Causeway Bay shopping area and nearby Victoria Park were clouded in tear gas, prompting thousands of protesters to flee as riot police moved swiftly to stymie a rally demanding meaningful autonomy after Beijing indicated it could tighten its grip on the Chinese territory.

Police deployed at least two water cannon trucks in the vicinity. They had issued warnings to protesters who occupied the area that they were attending an unauthorized rally and violating a government ban on face masks.

Some protesters stormed Xinhua's office in the city's Wan Chai neighbourhood. They smashed its glass door entrance and windows, splashed red ink, sprayed graffiti and set a small fire in the office lobby.

A volunteer medic escorts a woman affected by tear gas on Saturday . (Kin Cheung/The Associated Press)

Chinese banks and businesses linked to China have been frequently targeted by protesters as anger has built up against Beijing. The demonstrators accuse the central government of infringing on the freedoms guaranteed to Hong Kong when Britain returned the city to China in 1997.

Earlier Saturday, some protesters unearthed a goal post from a soccer field and metal railings to block the park's entrance.

Pro-democracy candidates running in this month's district council elections — who can meet with groups of 50 or fewer people without a police permit — held hustings at the park to try get around the rally ban. One candidate was pepper-sprayed in the face after he argued with police and was detained.

A demonstrator hurls a firebomb during a protest in Hong Kong on Saturday. (Vincent Yu/The Associated Press)

Hardcore protesters in full gear quickly regrouped in the vicinity, using plastic cones and metal railings to set up road barriers. In Wan Chai and other areas, protesters hurled gasoline bombs at police, who responded by firing more tear gas and a water cannon. A number of protesters were detained.

Police said in a statement that some masked rioters also damaged shops, committed arson and placed nails on the roads, threatening the safety of road users.

The chaos underlined the depth of dissent that began in early June over a now-shelved plan to allow extraditions to mainland China but have since swelled into a movement seeking other demands, including direct elections for Hong Kong's leaders.

Police in riot gear stand over people detained during protests in Hong Kong on Saturday. (Kin Cheung/The Associated Press)

A move last month by Hong Kong's leader, Carrie Lam, to invoke emergency powers to impose a face mask ban was seen as crimping the protesters' rights to assemble.

As the street battles continued late Saturday, thousands gathered at a public square overlooking the city's harbour for a police-approved rally. Some carried American flags to press for the passage of a U.S. bill that could place diplomatic action and economic sanctions on the city over human rights violations. U.S. lawmakers have passed the bill, which still needs Senate backing.

The increasingly violent unrest in Hong Kong has hurt the reputation of one of the world's top financial hubs. The city has slipped into recession for the first time in a decade as it grapples with the turmoil and the impact from the U.S.-China trade war.

More than 3,000 people have been detained in the protests. The civil disobedience has posed a big challenge to Beijing, which vowed Friday to prevent foreign powers from sowing acts of "separatism, subversion, infiltration and sabotage" in Hong Kong.

In a Communist Party document released after its Central Committee meeting this past week, Beijing said it would "establish and strengthen a legal system and enforcement mechanism" to safeguard national security in Hong Kong.

Hong Kong, which has a separate legal system from mainland China, has tried to enact anti-subversion legislation before, only to have the measure shelved amid formidable public opposition. Beijing may be indicating it is preparing to take matters into its own hands by having the National People's Congress issue a legal interpretation forcing the enactment of such legislation.