Media playback is unsupported on your device Media caption The BBC's Stephen McDonell reports: "The protesters were here in their thousands"

Hong Kong police have fired tear gas at an unauthorised protest held by tens of thousands of people to condemn an attack by armed masked men last week.

As a small group of protesters refused to disperse in the northern district of Yuen Long, police fired rubber bullets.

The demonstration took place where pro-democracy protesters had been attacked by suspected triad gang members.

Police have been accused of turning a blind eye and colluding with the attackers, claims they deny.

Hong Kong has seen seven weeks of anti-government and pro-democracy protests sparked by a controversial bill that would have enabled extraditions to mainland China.

The government has since halted the legislation but protesters have demanded its complete withdrawal, as well as an inquiry into police violence, democratic reform, and that the territory's leader Carrie Lam resign.

Why did police ban the rally?

Saturday's march had been banned by the police, a highly unusual move in the territory, where protests are usually allowed.

Police say they refused permission because they feared violent clashes between protesters and residents.

The rally was planned as a response to last Sunday's attack, in which about 100 men descended on Yuen Long's metro station, beating protesters - as well as passersby and journalists - with wooden and metal sticks.

The attack left 45 people injured and was widely blamed on triad gang members. They appeared to target those wearing black, the colour people had been told to wear for the protest.

Media playback is unsupported on your device Media caption A large group of masked men in white T-shirts stormed Yuen Long station

Triads are known to be active in Yuen Long - located in a rural northern district in Hong Kong, near mainland China - and many local villagers have also expressed opposition to the pro-democracy protests.

How did Saturday's violence break out?

Tens of thousands defied the police ban and approached Yuen Long on Saturday, marching down some of the main roads.

Police observed and filmed the start of the protest, and riot police could be seen on standby.

Police said some protesters were holding iron poles and shields, and "even removing fences from roads".

Image copyright Reuters Image caption Protesters came prepared with helmets and masks

Some protesters also surrounded and vandalised a police vehicle, "causing danger to the life of the police officers on board", they said.

Shortly after 17:00 local time (10:00 BST), police began firing several rounds of tear gas in an attempt to disperse the crowd.

The protesters - most wearing masks and hard hats - threw projectiles and swore at police - but also parted to allow ambulances to go through.

Later in the evening, in an attempt to clear several hundred demonstrators, police fired rubber bullets, injuring at least nine people, according to the AFP news agency.

Why are protesters angry at the police?

Protesters have been demanding an independent inquiry into police violence, saying police used excessive force in several anti-extradition bill and pro-democracy protests.

During Sunday's suspected triad attack, protesters said the police were slow to respond to emergency calls - and only appeared at the station after the attackers had left.

Demonstrators and pro-democracy legislators have alleged that the authorities - including the police and pro-government legislators - had advance knowledge of the attack.

One Yuen Long resident told the BBC Chinese service that a relative working in the police force had warned her, ahead of the attack, not to wear black clothes.

Police say suggestions that they colluded with criminal gangs were a "smear", and that 12 people have so far been arrested, including nine men with links to triads.

The chief executive's deputy, Matthew Cheung, apologised on Friday, saying "the police's handling fell short of residents' expectations".

However, his apology sparked outrage among police officers.

"[W]e have been violently charged and verbally abused. Off-duty we suffer online abuse, harassment and provocation... your works have completely written off our efforts in maintaining law and order," the Hong Kong Police Inspectors' Association said in an open letter.

Image copyright Reuters Image caption Protesters vandalised a police van at Saturday's protest

There have also been growing tensions between protesters and pro-Beijing groups.

Earlier this week, pro-Beijing legislator Junius Ho's office was ransacked, and his parents' graves were vandalised.

He had come under criticism after video footage showed him shaking hands with white-shirted men on Sunday shortly before the attacks.

He said he did not know about the attack, but defended the men, saying they were simply "defending their home and people".

Separately, Reuters news agency reports that, a week before the Yuen Long attack, a Chinese government official appeared at a local village banquet and encouraged the crowd to chase away protesters and "protect our home".

China's Liaison Office in Hong Kong has rejected "false rumours" linking it to the Yuen Long attack.

Timeline of events 2019

3 April - Hong Kong government introduces amendments to the city's extradition laws to the legislature that would allow criminal suspects to be extradited to mainland China.

9 June - In the first of many huge protests against the changes, an estimated million people march to government headquarters.

12 June - Anti-extradition bill protesters block roads and try to storm government buildings - police fire tear gas, rubber bullets and bean bag rounds at protesters, in the worst violence the city has seen in decades.

15 June - Hong Kong leader Carrie Lam indefinitely delays the bill in a dramatic reversal.

16 June - Despite this, an estimated two million people take to the streets demanding the complete withdrawal of the bill, an investigation into alleged police violence, and Carrie Lam's resignation.

21 June - As anger grows towards police, protests blockade police headquarters for 15 hours. They now also want protesters that were arrested to be exonerated.

1 July - On the anniversary of Hong Kong's handover from the UK to China, the Legislative Council (LegCo) building is stormed and broken into by protesters.

21 July- Protesters deface China's Liaison Office in Hong Kong. That same night mobs of men wearing white shirts attack protesters and commuters in Yuen Long station, near mainland China, in a new escalation of violence.