The castle was built by the Armenian Bagratid dynasty. In 1153 the castle was rebuilt, in 1386 the castle was destroyed by the Uzbek ruler Timur Lenk and then rebuilt and rebuilt several times. The last destruction occurred during the war between the Ottoman and Russian Empires in 1877-78.