Australian police have defended their actions after violently clashing with protesters during a demonstration against a visit by the Israeli president.

Video emerged of police charging and punching protesters during the rally in Sydney on Monday night, with a state parliament MP among those who said they were injured in the clashes. Police said 27 people were arrested, with nine later charged, and 10 officers assaulted.

Officers showed remarkable restraint, NSW Police Commissioner Mal Lanyon said Tuesday, adding they did what they needed to do.

Earlier, rally organisers had failed in their court bid to overturn police powers limiting their right to demonstrate during Isaac Herzog's visit.

The government invited Herzog to visit Australia after an antisemitic attack at Bondi Beach, saying it would help the Jewish community heal, despite objections from pro-Palestinian groups.

Fifteen people, including a ten-year-old girl, were killed on 14 December after two gunmen shot at crowds at an event celebrating the Jewish festival of Hanukkah.

Video footage of the protests outside Sydney's Town Hall and surrounding areas - police said 6,000 attended while organisers said it was 50,000 - appeared to show several physical confrontations between police and protesters, including officers punching protesters and dragging away Muslim men who were praying.

Josh Lees from the Palestine Action Group said the violence at the protest on Monday evening was the worst he has seen in recent years. We should have had the right to march, he told the Australian Broadcasting Corporation (ABC) radio.

He said all of this could have been avoided if the New South Wales (NSW) government had allowed the group to march from Town Hall to either the state parliament or Hyde Park.

NSW introduced restrictions on public protest after December's shooting, and a few days before Monday's rally introduced additional major event powers effectively giving police authority to shut down areas of the city. The rules allowed demonstrators to gather but forbade them from marching.

Protesters lost a legal bid to overturn the major event powers application just half an hour before the protest.

NSW Premier Chris Minns defended the police response, telling Channel 9's Today programme that authorities had been put in an impossible situation last night. He later urged the public not to look at a 10-second clip without the full context.

Assistant Commissioner Peter McKenna said police had been threatened, jostled and assaulted during a number of melees, rolling fights and authorities were significantly outnumbered by the protesters and the people who wanted to act in a violent and offensive manner.

Among the crowd last night was Jewish demonstrator Linda Feinberg, who came to show solidarity. I am appalled, it was a really damaging decision of Albanese to invite him [Herzog], she said, holding a placard that read Jews say no to genocide.

Sihal Jamila came with her young daughter. It's very important for me to be here, I'm the mother of two and one on the way, she told the BBC, her voice cracking. They're killing our children. This is ridiculous.

The speeches at Town Hall were peaceful, but tensions mounted afterwards when protesters began chanting let us march and police closed in.

As the atmosphere became fraught, pepper spray was deployed, which sent protesters running, but they were unable to leave the area due to police lines.

Minns said police had needed to keep protesters away from people attending an event with Herzog at a nearby convention centre.

Another protest is planned for Tuesday evening outside a Sydney police station, with organisers calling for charges against protesters to be dropped and for police officers who had used physical force to be investigated.

The Australian National Imams Council said the footage of Muslims men being dragged away while they were praying was shocking, deeply disturbing, and entirely unacceptable.

NSW Greens MP Abigail Boyd - who posted a photo of herself in a neck brace - said she was pushed and shoved by police at the protests despite telling them she was a member of parliament. I got pushed so hard my feet left the ground after I told them I was a member of parliament, she said.

Prime Minister Anthony Albanese, who is to meet Herzog later on Tuesday, said he was devastated by the scenes, saying they shouldn't be taking place, but defended the invitation to Herzog and said protesters undermined their cause at the protest.

Pro-Palestinian groups had objected to Herzog's visit, citing a UN commission last year which concluded that Herzog was among Israeli leaders who incited the commission of genocide against Palestinians in their speeches and statements.

It came after Herzog said it's an entire nation out there that is responsible for the 7 October 2023 Hamas attacks on Israel, and was also pictured signing a shell to be dropped on Gaza. His comments formed part of the legal case brought by South Africa in the International Court of Justice accusing Israel of genocide in Gaza.

Herzog has condemned the UN report, which he said took his words out of context, while the Israeli foreign minister called it distorted and false.