The integrity of the Byzantine Empire was threatened after a full-scale rebellion led by Bardas Skleros broke out in 976. After winning a series of battles, the rebels conquered Asia Minor. In the urgency of the situation, Georgian prince David III of Tao aided Basil; after a decisive loyalist victory at the Battle of Pankaleia, he was rewarded by lifetime rule of key imperial territories in eastern Asia Minor. David's rebuff of Basil in Bardas Phokas' revolt of 987, however, evoked Constantinople's distrust of the Georgian rulers. After the revolt's failure, David was forced to make Basil the legatee of his extensive possessions. In 1001, after the death of David of Tao, Basil inherited Tao, Phasiane, and Speri. These provinces were then organized into the theme of Iberia with the capital at Theodosiopolis. This forced the successor Georgian Bagratid ruler Bagrat III to recognize the new rearrangement. Bagrat's son George I, however, inherited a longstanding claim to David's succession. George, who was young and ambitious, launched a campaign to restore the Kuropalates's succession to Georgia and occupied Tao in 1015–1016. He entered in an alliance with the Fatimid caliph of Egypt, al-Hakim, forcing Basil to refrain from an acute response to George's offensive. The Byzantines were also involved in a relentless war with the Bulgarians, limiting their actions to the west. As soon as Bulgaria was conquered in 1018 and al-Hakim was dead, Basil led his army against Georgia. Preparations for a larger-scale campaign against the Kingdom of Georgia were set, beginning with the re-fortification of Theodosiopolis.