section_path: History/Middle Ages (7th century – 1517)
section_name: Middle Ages (7th century – 1517)
paragraph_text: Middle Ages (7th century – 1517)
  
  The Byzantines were able to regain control of the country after a brief Sasanid Persian invasion early in the 7th century amidst the Byzantine–Sasanian War of 602–628 during which they established a new short-lived province for ten years known as Sasanian Egypt, until 639–42, when Egypt was invaded and conquered by the Islamic caliphate by the Muslim Arabs. When they defeated the Byzantine armies in Egypt, the Arabs brought Islam to the country. Some time during this period, Egyptians began to blend in their new faith with indigenous beliefs and practices, leading to various Sufi orders that have flourished to this day. These earlier rites had survived the period of Coptic Christianity.
  
  In 639 an army were sent in Egypt by the second caliph, Umar, under the command of Amr ibn al-As. They defeated a Roman army at the battle of Heliopolis. Amr next proceeded in the direction of Alexandria, which surrendered to him by a treaty signed on 8 November 641. Alexandria was regained for the Byzantine Empire in 645 but was retaken by Amr in 646. In 654 an invasion fleet sent by Constans II was repulsed.
  
  The Arabs founded the capital of Egypt called Fustat, which was later burned down during the Crusades. Cairo was later built in the year 986 to grow to become the largest and richest city in the Arab caliphate, second only to Baghdad.
  
  The Abbasid period was marked by new taxations, and the Copts revolted again in the fourth year of Abbasid rule. At the beginning of the 9th century the practice of ruling Egypt through a governor was resumed under Abdallah ibn Tahir, who decided to reside at Baghdad, sending a deputy to Egypt to govern for him. In 828 another Egyptian revolt broke out, and in 831 the Copts joined with native Muslims against the government. Eventually the power loss of the Abbasids in Baghdad led for general upon general to take over rule of Egypt, yet being under Abbasid allegiance, the Tulunid dynasty (868–905) and Ikhshidid dynasty (935–969) were among the most successful to defy the Abbasid Caliph.
  
  Muslim rulers remained in control of Egypt for the next six centuries, with Cairo as the seat of the Fatimid Caliphate. With the end of the Ayyubid dynasty, the Mamluks, a Turco - Circassian military caste, took control about 1250. By the late 13th century, Egypt linked the Red Sea, India, Malaya, and East Indies. The mid-14th-century Black Death killed about 40% of the country's population.