The High Court of Justice rejected a petition Monday by a coalition of NGOs to change the route of the annual Jerusalem Day march so that it does not pass through the Muslim Quarter of the Old City.

The justices — who said they reached their decision “with a heavy heart” — ordered police to arrest and prosecute any participants engaging in violence, vandalism or any other overt displays of anti-Arab racism.

Justice Elyakim Rubinstein promised to ramp up efforts to combat the increasingly pervasive nationalistic attacks against Arab residents of Jerusalem, and noted that the video clips provided by the petitioners — which show participants in the 2014 march shouting “Death to Arabs” and “Muhammad is dead” — were difficult to watch.

“This is not freedom of speech, this is freedom to incite,” Rubinstein said, and recommended that both participants and police should be made aware that shouting racist slogans could result in criminal prosecution.

During the hearing, Justice Isaac Amit said that it was time to adopt a “zero-tolerance policy for the ‘Death to Arabs’ chant that includes arrests and indictments,” and added that those who wish to chant the slogan could do so from behind bars.

Amit also called on parade organizers and leading rabbis to publicly denounce hate speech, and urged yeshiva heads to instruct their students that participation in displays of anti-Arab racism would result in their suspension.

A representative from the Jerusalem district police department assured the justices that the police were prepared to document, arrest and indict participants who shout the slogans.

The ruling also said that Arab residents of the Old City would be given full access to their homes and businesses during the march.

Last week, the organizations Tag Meir and Ir Amim — who say that the national holiday has increasingly become a rally of racism, hatred and incitement to violence against Jerusalem’s Palestinian population — petitioned the High Court to change the route of the march so that it would not pass through the Muslim Quarter.

As part of the event — which celebrates the reunification of Jerusalem following the Six Day War in 1967 — thousands of Israelis attend the annual march of flags, which traditionally enters the Old City via the Muslim Quarter en route to the Western Wall.

This year, the march is set to take place on May 17.

“March organizers and police do not have a legal basis to require residents and merchants to barricade themselves inside their homes until the storm has passed,” attorney Eitay Mack wrote in the petition.

The group says the petition was submitted after the Jerusalem Police refused to change the route, despite the increasing number of incidents of verbal and physical violence.

In 2014, flag-carrying Israelis were filmed skirmishing with Palestinians at Damascus Gate. On nearby Salah al-Din Street, Palestinians stoned an Egged bus, injuring seven Israelis. The previous year, similar disturbances led to the arrest of 23 Palestinians and 13 Israelis.

Elhanan Miller contributed to this report.