SAN JOSE — A day after a melee erupted outside a Donald Trump rally, the San Jose police chief and mayor on Friday defended themselves from a national backlash over their handling of the dramatic and at times violent protest.

On radio talk shows and across social media, some called for Mayor Sam Liccardo’s resignation because of his comments suggesting that Trump was to blame for igniting violence, while police were criticized for failing to protect Trump supporters from angry protesters throwing punches, water bottles and traffic cones. Some videos showed those attacks and suggested they were unprovoked, but others showed Trump supporters taunting protesters, ripping their Dump Trump signs and throwing the first punches.

While it appeared to many onlookers that police allowed the violence to proceed unchecked, San Jose police Chief Eddie Garcia insisted that it was more important for police to hold their “skirmish line” formations than to stop individual attacks. Four arrests were made.

“We are not an ‘occupying force’ and cannot reflect the chaotic tactics of the protesters,” Garcia told reporters. Unless a victim’s life was in peril or the violence was “spiraling out of control,” he said, officers held back to avoid inciting more violence and having the crowd turn on officers. He also said the 250 police weren’t enough to control the roughly 400 protesters.

Liccardo praised the police restraint.

“I can say if there was a single excessive baton blow on anyone in that crowd,” Liccardo said Friday, “that would have made national news.”

San Jose — where Latinos make up a third of the population — became the focus of international attention anyway. Videos exploded on news stations and social media Thursday evening showing marauding protesters turning on Trump supporters.

Demonstrators ripped a “Build the Wall” T-shirt — a reference to Trump’s promise to build a wall along the border with Mexico — off the back of one man.

It was the largest violent political protest seen in San Jose in decades.

The violence was universally decried by pundits and politicians, including Trump’s presidential opponent Hillary Clinton, who said, “It’s deplorable no matter who’s doing it.” At a rally Friday in Berkeley, candidate Bernie Sanders called the violence “absolutely and totally unacceptable,” saying people considering violence “are not the supporters that I want.”

On Twitter, Trump offered a brief note about his stop: “Rally last night in San Jose was great. Tremendous love and enthusiasm in the hall. Big crowd. Outside, small group of thugs burned Am flag!”

By midday Friday, Liccardo — a Clinton supporter — was trending on Facebook after he said late Thursday that “at some point Donald Trump needs to take responsibility for his irresponsible behavior.” His comments ranked as the fourth most-talked about topic around the globe.

Even some of Liccardo’s political allies took him to task, including former San Jose City Councilman Pete Constant, a Republican who often worked closely with Liccardo.

“San Jose Mayor blames residents going to a presidential campaign event for being attacked by those who oppose the candidate — another case of blaming the victim?” Constant posted on Facebook. “No matter what your political persuasion, you should not be subject to violence for your beliefs — EVER!”

In a phone interview Friday from Washington, D.C., where he traveled after the protest, Liccardo didn’t let Trump off the hook.

“I’m absolutely clear about the fact that people who commit acts of violence are responsible for their own actions,” Liccardo said, “but Mr. Trump is also responsible, as we all are, for our own speech.”

During the protest, police in riot gear maintained shoulder-to-shoulder lines, trying to separate protesters from Trump supporters. But they weren’t always at the right place at the right time, especially at the back of the convention hall shortly after Trump’s speech ended and the altercations began. Some Trump opponents appeared to attack supporters without provocation, while other supporters shouted “Mexicans go home!”

As the evening wore on, the long lines of police standing firm or marching down streets effectively dispersed the crowd that often taunted them and threw bottles and parking signs their way. One officer’s wrist was injured when a metal object hit him, the police chief said.

Garcia announced Friday that he has formed a task force to review video evidence and investigate the assaults and other crimes from the protest. He is also asking for people who were there to give police their videos “so we can root out those whose intentions were to disrupt our civil democratic process.”

It was unclear who was responsible for the violence, and the police chief said he didn’t know whether those arrested were local. A small group of protesters wore bandannas over their faces, a tactic also used by the so-called “anarchists” during the Occupy movement in Oakland. Many protesters interviewed at the scene Thursday night live in East San Jose and said that while they are staunch opponents of Trump, they feared the violence only fed into the criminal stereotype Trump promotes.

Across the country, as Trump’s anti-immigrant rhetoric has ramped up, protests have been building outside each of his rallies, including in Burlingame and San Diego.

In many ways, San Jose, with its history of Latino civic activism dating back to Cesar Chavez’s farmworker strikes, was ripe for Thursday’s protest.

“It’s sort of a sleeping Giant in many ways,” said Garrick Percival,﻿ associate professor of political science at San Jose State University. “It can be dormant, but if there are outside influences that stoke these strong feelings, I think that is really in line with a lot of activism that has happened in this city over the decades.”

Percival said he wouldn’t be surprised to see rising tensions overall and “we can expect more of that as the summer gets longer and hotter and the rhetoric gets ramped up by Trump and his supporters.”

Staff writers Mark Gomez, Ramona Giwargis and Matthew Artz contributed to this report. Contact Julia Prodis Sulek at 408-278-3409. Follow her at Twitter.com/juliasulek