Throughout the uprisings in the 19th century, the fortified urban centres on the island, including Heraklion, served as places of refuge for Muslim populations living in the outlying countryside. This created numerous problems, exacerbating the predicament of Christian townsfolk, who often fell victim to violent attacks by frenzied Muslims, as occurred in June 1821.
In 1830 Crete was ceded to Mehmet Ali, ruler of Egypt, and remained under Egyptian domination until 1840, when it was returned to Ottoman hands. Under the Egyptians, roads, bridges and fortifications were built or repaired, the Venetian port was dredged and the aqueduct extended.
The town remained the capital of Crete until the mid-19th century, when the seat of Ottoman administration was transferred to Chania.