With the annexation of Jerusalem by Muhammad Ali of Egypt in 1831, foreign missions and consulates began to establish a foothold in the city. In 1836, Ibrahim Pasha allowed Jerusalem's Jewish residents to restore four major synagogues, among them the Hurva. In the countrywide Peasants' Revolt, Qasim al-Ahmad led his forces from Nablus and attacked Jerusalem, aided by the Abu Ghosh clan, and entered the city on 31 May 1834. The Christians and Jews of Jerusalem were subjected to attacks. Ibrahim's Egyptian army routed Qasim's forces in Jerusalem the following month.