Coordinates: 40°38′N 48°40′E / 40.633°N 48.667°E
Shamakhi or Shamakhy (Azerbaijani: Şamaxı) is a rayon of the Republic of Azerbaijan. Its administrative center is Shamakhi city.
The town lies 106 kilometres (66 mi) west of Baku. It has more than 20,000 inhabitants, among them Azerbaijanis (more than 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.