Police fired numerous tear gas canisters while charging at protesters near the Hong Kong legislature building shortly after midnight Monday, dispersing the crowd following a daylong protest that marked the 22nd anniversary of the former British colony's handover to China.

Officers in full riot gear stormed the site and dispersed hundreds of protesters who have engaged in occasional standoffs with police throughout the day on streets surrounding the government headquarters and the legislature, local media reported.

Police soon regained control of the government complex as the crowd scattered and most of the protesters, including those who had occupied the legislature building, left before midnight.

Several hundred protesters had managed to break through reinforced glass windows and a metal gate to enter the legislature building earlier in the day. Wearing construction helmets, goggles and facemasks, they destroyed closed-circuit television cameras and prepared barriers for an extended stay.

They also painted the legislative chamber's walls with slogans such as "No to China extradition," "Release the martyrs" and "Carrie Lam step down," while others put up a colonial era Hong Kong flag. More than 40 people were injured, including at least two legislators who tried to stop the protesters, during the attempted takeover of the building, according to local media.

After meeting with her security staff and police chief in the early hours Tuesday, Chief Executive Carrie Lam said she felt "angered and disheartened" to witness the acts carried out by the people who stormed and vandalized the legislature building.

"This is something that we should seriously condemn because nothing is more important than rule of law in Hong Kong," she told reporters. "We will pursue responsibility against those who committed illegal acts and broke the law."

Regarding the public outcry caused by the bill, Lam insisted she will reflect on the matter and communicate with all including young people "with utmost sincerity," while dismissing any possibility she would resign as demanded by the protesters.

A protest march that according to the organizer drew some 550,000 people also took place Monday to demand the complete withdrawal of an extradition bill that could facilitate the transfer of fugitives to mainland China. Hong Kong's government has said work on the bill has been halted, and that even if passed it would be allowed to expire in July 2020.

Police said turnout for the march was about 190,000.

"(Suspending the legislation) is absolutely not acceptable," said march participant Howard Wu, a 20-year-old university student in Britain who came back to Hong Kong for summer break.

"It's just a delaying tactic. If the bill was passed, the Chinese authorities could catch whoever they want. That would spell the end for (Hong Kong's) 'one country, two systems' and judicial independence," he said.

The controversial bill would allow individuals in Hong Kong, including locals and foreigners, to be extradited to jurisdictions with which the territory has no such agreement, including mainland China.

At the nearby Hong Kong Convention and Exhibition Centre, Lam joined other local and central government officials for a flag-raising ceremony and cocktail party held every July 1 to mark the anniversary of the end of British rule.

But for the first time since the 1997 handover, members of the public were not allowed to attend, while a heavy police presence in the area kept hundreds of protesters at bay.

"The incidents that happened in recent months have led to controversies and disputes between the public and the government," Lam told hundreds of guests.

"I will learn my lesson and ensure that the government's future work will be closer and more responsive to the aspirations, sentiments and opinions of the community," she said.

Security Secretary John Lee said early Monday that the people of Hong Kong have the right to free speech. "But it is best to tolerate other people's rights and freedom when doing so," he added.

The extradition law amendment was proposed by the Hong Kong government in March, in part to facilitate extradition of a Hong Kong citizen to Taiwan for his alleged involvement in a murder case there. But the bill raised concern among businesses and residents that Hong Kong's judicial independence would be jeopardized, with some fearing Chinese authorities would use it to crack down on pro-democracy activists and critics of the Communist Party-led Beijing government.

Amid growing opposition to the bill in Hong Kong, Taiwan said it would not seek the suspect's extradition. But the Hong Kong government proceeded with the legislative move, aiming to pass the bill by July.

Last month, millions of protesters took to the streets to demand the bill's withdrawal and Lam's resignation. Largely peaceful protests turned violent on June 12 as police clashed with demonstrators, using tear gas and other riot tactics against them.

A father of two girls who agreed to be identified only by his surname Wong listed the five demands protesters have put forward -- namely, withdrawing the bill, dropping charges against protesters, revoking the characterization of the June 12 rally as a riot, setting up an independent probe against police brutality and Lam stepping down.

"Even if the government is willing to withdraw the bill now, the other four demands would still need to be addressed," Wong said. Apologizing for her handling of the bill, Lam agreed to suspend it indefinitely, but insisted she would not withdraw it. She also vowed to stay in office until her tenure ends in 2022.

Speaking ahead of the anniversary, British Foreign Secretary Jeremy Hunt said Britain has an "unwavering" commitment to the Sino-British Joint Declaration that oversaw the handover of the former colony to China.

But Chinese foreign ministry spokesman Geng Shuang said Monday that Britain's rights and responsibilities concerning Hong Kong issues have already been discharged, and China expresses strong dismay and resolute opposition to Britain's frequent interference in the internal affairs of China.

The European Union also commented on the march and the legislature protest, saying that despite the actions of those who tried to occupy the legislature building, the "vast majority" of Hong Kong protesters have peacefully exercised their fundamental right to assemble and to protest.

"It is all the more important to exercise restraint, avoiding escalatory responses," the statement reads.

Related coverage:

IN PHOTOS: Hong Kong protests against extradition bill

Hong Kong people march demanding withdrawal of extradition bill