Shamakhi or Shamakhy is a rayon of the Republic of Azerbaijan, and a town in the rayon. It is the historical center of the region of Shirvan.
The town lies 106 kilometres (66 mi) west of Baku. It has more than 20,000 inhabitants, among them Azerbaijanis (95%) and Russians. Once Shamakhi was famous for its traditional dancers, the Shamakhi dancers. Though Shamakhi has suffered from attack, earthquake and siege, it remains rich in historical and cultural monuments, chief among them the Baba Zinda near the settlement of Maraza.In its history eleven major earthquakes have rocked Shamakhi, but each time it was reconstructed by its inhabitants due to role as economic and administrative capital of Shirvan and one of the key towns on the way of the Silk Road. The only building to have survived eight of the eleven earthquakes is the landmark Juma Mosque (8th century CE).
Shamakhi was first mentioned as Kamachia by ancient Greco-Roman geographer Claudius Ptolemaeus in the 1st to 2nd century CE. It was an important town during the Middle Ages and served as capital of the Shirvanshah state from the 8th to 15th centuries and capital of the independent Shirvan Khanate, also known as khanate of Shamakhi. The catholic friar, missionary and explorer William of Ruysbroeck passed there on his return journey from the Mongol Great Khan's court.
Shamakhi was the capital of the Shamakhi Governorate of the Russian Empire until the devastating earthquake of 1859, when the capital of the province was transferred to Baku. The importance of the city declined sharply afterwards. According to the Brockhaus and Efron Encyclopedic Dictionary , Shamakhi had 20008 inhabitants (10450 males and 9558 females), of which 3% were Russians, 18% were Armenians, and 79% "Azerbaijani Tatars." With regard to religion, 79% of the population was Muslim, of which 22% was Sunni and the rest Shiite; the remaining 21% was "Armeno-Gregorian" (members of the Armenian Apostolic Church) and "Pravoslav" (Orthodox).The "Queen of Shemakha" is a major protagonist in the poem "The Tale of the Golden Cockerel" by Alexander Pushkin, on which the opera "The Golden Cockerel" by Nikolay Rimsky-Korsakov was based. The character, however, is totally fictional and bears no actual relation to the city.