section_path: History/518–717
section_name: 518–717
paragraph_text: 518–717
  
  The reign of Justinian I was a watershed in Byzantine history. Following his accession in 527, the law-code was rewritten as the influential Corpus Juris Civilis and Justinian produced extensive legislation on provincial administration; he reasserted imperial control over religion and morality through purges of non-Christians and "deviants"; and having ruthlessly subdued the 532 Nika revolt he rebuilt much of Constantinople, including the original Hagia Sophia. Justinian took advantage of political instability in Italy to attempt the reconquest of lost western territories. The Vandal Kingdom in North Africa was subjugated in 534 by the general Belisarius, who then invaded Italy; the Ostrogothic Kingdom was destroyed in 554.
  
  In the 540s, however, Justinian began to suffer reversals on multiple fronts. Taking advantage of Constantinople's preoccupation with the West, Khosrow I of the Sasanian Empire invaded Byzantine territory and sacked Antioch in 540. Meanwhile, the emperor's internal reforms and policies began to falter, not helped by a devastating plague that killed a large proportion of the population and severely weakened the empire's social and financial stability. The most difficult period of the Ostrogothic war, against their king Totila, came during this decade, while divisions among Justinian's advisors undercut the administration's response. He also did not fully heal the divisions in Chalcedonian Christianity, as the Second Council of Constantinople failed to make a real difference. Justinian died in 565; his reign saw more success than that of any other Byzantine emperor, yet he left his empire under massive strain.
  
  Financially and territorially overextended, Justin II (r. 565–578) was soon at war on many fronts. The Lombards, fearing the aggressive Avars, conquered much of northern Italy by 572. The Sasanian wars restarted that year, and continued until the emperor Maurice finally emerged victorious in 591; by that time, the Avars and Slavs had repeatedly invaded the Balkans, causing great instability. Maurice campaigned extensively in the region during the 590s, but although he managed to re-establish Byzantine control up to the Danube, he pushed his troops too far in 602—they mutinied, proclaimed an officer named Phocas as emperor, and executed Maurice. The Sasanians seized their moment and reopened hostilities; Phocas was unable to cope and soon faced a major rebellion led by Heraclius. Phocas lost Constantinople in 610 and was soon executed, but the destructive civil war accelerated the empire's decline.
  
  Under Khosrow II, the Sassanids occupied the Levant and Egypt and pushed into Asia Minor, while Byzantine control of Italy slipped and the Avars and Slavs ran riot in the Balkans. Although Heraclius repelled a siege of Constantinople in 626 and defeated the Sassanids in 627, this was a pyrrhic victory. The early Muslim conquests soon saw the conquest of the Levant, of Egypt, and of the Sassanid Empire by the newly-formed Arabic Rashidun Caliphate. By Heraclius' death in 641, the empire had been severely reduced economically as well as territorially—the loss of the wealthy eastern provinces had deprived Constantinople of three-quarters of its revenue.
  
  The next seventy-five years are poorly documented. Arab raids into Asia Minor began almost immediately, and the Byzantines resorted to holding fortified centres and avoiding battle at all costs; although it was invaded annually, Anatolia avoided permanent Arab occupation. The outbreak of the First Fitna in 656 gave Byzantium breathing space, which it used wisely: some order was restored in the Balkans by Constans II (r. 641–668), who began the administrative reorganisation known as the " theme system ", in which troops were allocated to defend specific provinces. With the help of the recently rediscovered Greek fire, Constantine IV (r. 668–685) repelled the Arab efforts to capture Constantinople in the 670s, but suffered a reversal against the Bulgars, who soon established an empire in the northern Balkans. Nevertheless, he and Constans had done enough to secure the empire's position, especially as the Umayyad Caliphate was undergoing another civil war.
  
  Justinian II sought to build on the stability secured by his father Constantine but was overthrown in 695 after attempting to exact too much from his subjects; over the next twenty-two years, six more rebellions followed in an era of political instability. The reconstituted caliphate sought to break Byzantium by taking Constantinople, but the newly crowned Leo III managed to repel the 717–718 siege, the first major setback of the Muslim conquests.