The Gemara in Masechet Erubin states that if enemies of the Jews wage battle against a Jewish community on Shabbat, then everything necessary to effectively respond to the threat and defend the community should be done, even if this requires violating Shabbat. However, the Gemara says that this applies only if the enemies seek to kill Jews. If their intent is to seize the Jews’ property, then the community is required to surrender their money. The Shabbat prohibitions are waived for the sake of saving human life, but not for the sake of protecting property, and so desecrating Shabbat is not allowed if enemies come to destroy or seize Jews’ property.
However, the Rosh (Rabbenu Asher Ben Yehiel, Germany-Spain, 1250-1327) cites the Or Zarua (Rav Yishak of Vienna, 13th century) as ruling that nowadays, even if gentiles attack to destroy or seize Jews’ property, there is reason to fear that they are prepared also to kill. The Gemara in Sanhedrin (82) addresses the case described by the Torah of "Ha’ba Ba’mahteret" – a burglar who breaks into one’s home to steal, and whom the Torah allows the homeowner to kill. Although the burglar’s intent is to rob, the Gemara explains, the Torah nevertheless permits the homeowner to kill the burglar because the burglar anticipates the possibility of a violent confrontation. The burglar breaks into the house knowing full well that if he is detected, the homeowner will defend his property and put up a fight. As such, the burglar comes in anticipating the possibility of having to kill the homeowner. This anticipation renders him a "Rodef" ("pursuer"), who seeks to kill, and the Torah therefore allows the homeowner to kill the burglar in self-defense. The Or Zarua applied this concept to situations where violent groups seek to loot and rob. Since they anticipate the likelihood of resistance, they can be presumed to be prepared to kill. Therefore, if they come on Shabbat, affected communities may violate Shabbat in order to protect their property – as they are in effect protecting their lives, as well.
The Shulhan Aruch cites the Gemara’s ruling, and then adds, "There is one who says" (referring to the Or Zarua) that nowadays, one may violate Shabbat to defend against groups who come to seize property, given the potential risk to life. The Kaf Ha’haim (Rav Yaakob Haim Sofer, Baghdad-Jerusalem, 1870-1939) writes that when the Shulhan Aruch uses the expression "Yesh Mi Sh’omer" ("There is one who says"), he accepts that ruling. Thus, the accepted Halacha permits violating Shabbat to protect a community from looters, even if the looters intend only to rob, because they mighty also perpetrate acts of violence in the process. The Magen Abraham (Rav Abraham Gombiner, 1633-1683), cited by the Mishna Berura (Rav Yisrael Meir Kagan of Radin, 1839-1933), maintains that this applies only if a community comes under attack. If people come to steal from only one Jew, the Jew may not violate Shabbat for the sake of defending his property.
As for the practical Halacha, then, when groups of rioters are looting in Jewish neighborhoods on Shabbat, it would be permissible to violate Shabbat in order to protect the threatened property, given the real possibility of a threat to life.
Summary: If groups of rioters are looting in a Jewish neighborhood on Shabbat, it is permissible to violate Shabbat in order to protect the threatened property, given the possibility that the looters might resort to life-threatening violence.