From the conquest 642 A.D. until 868, Egypt was a province ruled either from Medina, Damascus or Baghdad, but from that time, 868, Egypt gained a sort of an autonomy when two dynasties the Tulunids followed by the Ikhshids ruled Egypt as a separate country until the Fatimids.