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 1834 Arab revolt in Palestine, Qasim al-Ahmad led his forces from Nablus and attacked Jerusalem, aided by the Abu Ghosh clan, 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.
Ottoman rule was reinstated in 1840, but many Egyptian Muslims remained in Jerusalem and Jews from Algiers and North Africa began to settle in the city in growing numbers. In the 1840s and 1850s, the international powers began a tug-of-war in Palestine as they sought to extend their protection over the region's religious minorities, a struggle carried out mainly through consular representatives in Jerusalem. According to the Prussian consul, the population in 1845 was 16,410, with 7,120 Jews, 5,000 Muslims, 3,390 Christians, 800 Turkish soldiers and 100 Europeans. The volume of Christian pilgrims increased under the Ottomans, doubling the city's population around Easter time.
In the 1860s, new neighbourhoods began to develop outside the Old City walls to house pilgrims and relieve the intense overcrowding and poor sanitation inside the city. The Russian Compound and Mishkenot Sha'ananim were founded in 1860. In 1867 an American Missionary reports an estimated population of Jerusalem of 'above' 15,000, with 4,000 to 5,000 Jews and 6,000 Muslims. Every year there were 5,000 to 6,000 Russian Christian Pilgrims. In 1874 Jerusalem became the centre of a special administrative district, independent of the Syria Vilayet and under the direct authority of Istanbul called the Mutasarrifate of Jerusalem.
Until the 1880s there were no formal orphanages in Jerusalem, as families generally