The ancient Shamkir was built on 30 hectares in the 5-6th centuries on the left bank of the Shamkir river on a trade route crossing Barda, Ganja and Tbilisi. In medieval Azerbaijan, Shamkir was one of the prosperous cities with grandiose buildings, good water supply and sewage system, big and crowded markets and developed handicrafts. 9th century historian Ahmad al-Balazuri notes that Salman ibn Rabia al-Bahili conquered the ancient town of Shamkir. After Arab invasion, in 854-855, great commander Buga rebuilt the town and settled the Caspians there. They sub­sequently adopted Islam. He brought merchants from Barda and named the city Mutavakkiliyya after a caliph. In early Middle Ages the town thrived on the Silk Way and turned into a signifi­cant centre in the 9-10th centuries. In the 13th, the Mongols invaded the town and destroyed it despite the resistance from the local people. The town lost its significance afterwards. Shamkir was known as Samkur in the Middle Ages and was looted several times as a result of foreign invasions. Local residents, fed up with such invasions, left the ancient town and built a new settlement 9-10 km away. During its renaissance in the 9-12th centuries, the town was con­quered by the Seljuk and, as part of the Ganja khanate, was occupied by Russia in the 19th century