In May 1703, during
Friday prayer at the
al-Aqsa Mosque, and while Mehmed Pasha was leading a punitive expedition around
Nablus, a rebellion against the government was announced. The
mutasallim appointed by Mehmed Pasha and the small number of troops who had been left to govern the city were apprehended by the Jerusalemite rebels with key assistance from the local
sipahi and Janissary units. The rebels also freed the inmates of the city's prison. Once word of the
ulamas call for revolt spread, the urban Jerusalemites were joined by peasants from the villages in the countryside. The rebels prepared Jerusalem's defenses to counter an assault by Mehmed Pasha and his troops. However, Muhammad ibn Mustafa did not trust imperial overtures and demanded stronger guarantees before ending the revolt. The population was split between the two camps, and the rivalry turned violent when Muhammad ibn Mustafa waged an armed campaign against the loyalists. The clashes peaked with a major battle in the narrow alleyways around the
Bab al-Huta gate in the northern part of the city. The battle ended with dozens of fatalities and mass defections from Muhammad ibn Mustafa's camp. The loyalist camp was barricaded in the
citadel with the
qadi, awaiting the intervention of the imperial army. Clashes between the rival camps began anew in late 1705, around the time that the imperial army was departing from
Damascus. The imperial army met generally ineffective resistance in the hinterland of Nablus, where peasant irregulars harried them along the way to Jerusalem. Once the Ottomans reached Jerusalem's environs in October, Muhammad ibn Mustafa decided to escape from the city with dozens of his followers through the
Damascus Gate and the
Moroccan Gate on 28 October, during the evening. Muhammad ibn Mustafa was captured by the Ottoman authorities, sent to
Istanbul, and was executed there in 1707. ==Aftermath and legacy==