The city remained Ottoman for a further three centuries, until in 1802 it was retaken by Saudi revolt, who were in alliance with the House of Saud. These forces then continued to take Mecca and Medina. The loss was keenly felt by the Ottoman Empire, which viewed itself as the protector of the Holy Cities. The Ottoman Sultan, Mahmud II, called upon his nominal Viceroy in Egypt Muhammad Ali, who launched an attack on the Hejaz and reconquered Ta'if in 1813.