Following the Muslim conquests and the establishment of the frontier between the Byzantine Empire and the Caliphate along the Taurus Mountains, Tyana became important as a military base due to its strategic position on the road to Cilicia and Syria via the Cilician Gates, which lie some 30 km to the south. Consequently, the city was frequently targeted by Muslim raids. The city was first sacked by the Umayyads after a long siege in 708, and remained deserted for some time before being rebuilt. It was then occupied by the Abbasid caliph Harun al-Rashid in 806. Harun began converting the city into a military base and even erected a mosque there, but evacuated it after the Byzantine emperor Nikephoros I bought a peace.