The foundation of the city of Guba dates back to the 15th century. In 1735, the city was transformed into the capital of the Guba Khanate, which encompassed the modern territories of northeastern Azerbaijan and the southern part of Dagestan. This khanate emerged as a result of ongoing conflicts among the Dagestani tribes. The founder of the Guba Khanate and its dynasty, Hussein Khan, hailed from the Kaitag people, an elder branch of the Utsmi clan. In the mid-17th century, this branch was nearly eradicated during a civil war, but a loyal attendant managed to hide the young Hussein and took him to the Kumyk shamkhal—the supreme ruler of the Dagestani tribes.
At the shamkhal court in Tarkh (near present-day Makhachkala), Hussein grew up and, upon reaching adulthood, began serving the Persian Shah in Salian (south of Baku). There, he converted to Shiism and married the daughter of a nobleman from the capital, Isfahan. The Shah granted his heir, Sultan-Ahmed, the title of Khan of Salian and Khudat.
Khudat, a small town adjacent to Khachmaz, was a center of the Gusar Plain at the time. Upon Sultan-Ahmed’s return, it became a bastion of Shiism on the edge of Sunni Dagestan. In 1711, the Lezgins revolted under the leadership of Hadji-Davud, akin to Imam Shamil, but instead of fighting against Christian Russia, they battled Shiite Persia, supported by the Turks. The Lezgins captured Khudat and massacred the despised Shiite khans, yet history repeated itself as the courtiers managed to save the young Hussein-Ali Khan and secretly transport him to the village of Tayirjar in the upper reaches of the Samur River.
There, the Shiite khan lay low for a time, aware of his lineage and having received an appropriate education, with no traitors found among his circle. His moment arrived in 1735 when Nadir Shah, the “Iranian Peter I,” invaded Dagestan, seeking to reclaim territories lost by Iran after the fall of the Safavids. Hussein-Ali did not return to his native Khudat under Persian rule; instead, he settled in Guba on the Gudialchai River, at the site of the ancient, semi-mythical city of Khobota. In 1747, after Nadir Shah was assassinated by conspirators and local rulers across Azerbaijan proclaimed khanates one after another, Hussein-Ali had no choice but to follow suit.
Situated at the Great Gateway of the Caucasus, between Iran and Turan, the Guba Khanate was unlike any other. Shiite Turkic nobility ruled over Sunni Lezgins, and remarkably, the khans managed to turn this situation to their advantage. The Sunni clergy in Guba predominated over the Shiite clergy, allowing the Shiite khan to operate independently, extending his secular authority even into areas traditionally controlled by imams and qazis.
Moreover, the Guba khans reestablished ties with the Kaitag Utsmis, thereby solidifying their authority among the mountain dwellers. However, the Lezgins remained distrustful of the khan, prompting him to invite those persecuted elsewhere in the Caucasus—Armenians (to Khachmaz), Turkic-speaking Shiite gypsies (to Garachi), and primarily, mountain Jews, whose “capital” remained Guba.
On the Gusar Plain and in the mountain gardens, fruits and saffron were cultivated, while the best carpets in the North Caucasus were woven in the auls. Most importantly, the Guba Khanate, like all of Dagestan, had its own weapons production. The trade wealth, military readiness, and bravery of the mountain people were all utilized by Fatali Khan, who ascended to the throne in 1758. By the end of the century, he had effectively built a small empire stretching from Derbent (which became the main city of the khanate) to the Persian city of Ardabil. In the 1760s, his vassals included the khans of Baku and Shamakhi, and by dethroning their dynasties, Fatali could have claimed the ancient title of Shirvanshah.
As he expanded his territories, he astutely chose allies, whether they were Dagestani princes or the khans of neighboring Sheki, and at the height of his power, he believed he was no longer dependent on them. This was a mistake: in the 1770s, Dagestani mountaineers invaded Guba, defeated the Shah’s guard, and forced Fatali to flee to Salian. There, nearly losing his conquests, the khan decided to go all in on finding new allies, sending an envoy to St. Petersburg with the keys to Derbent. Soon after, a Russian army, led by generals with German surnames, arrived in Dagestan. In 1775, Russia established a protectorate over the Guba Khanate, strategically opting not to interfere in the internal affairs of its vassal. This arrangement allowed the khan to regain his territories and continue his military campaigns, while the Tsar found it more convenient to negotiate with the khan’s heirs regarding local power dynamics.
In the 1780s, Fatali Khan expanded his influence by making vassals of Lankaran, Ardabil, and Sheki, successfully waging war against the powerful Karabakh Khanate. His reputation grew, earning respect even from regions like Gilan and Tabriz. However, this success came crashing down in 1789 with the death of the khan. His heirs rapidly squandered their father’s achievements, and by 1806, the remnants of the khanate were easily absorbed by Russia.
For several years, Guba was governed by a council of four beks and a naib (governor), with Mirza Mamed, a Baku Khan, serving as naib. The Guba Khanate was officially abolished in 1810 and transferred to direct control of the Guba commandant. By 1813, following the war, Persian claims to the region were relinquished. In 1830, Guba became the center of a district, initially part of the Caspian Province, then the Derbent Governorate in 1846, and finally included in the Baku Governorate after its division in 1860.
By the early 20th century, Guba had developed into a medium-sized district town with a population of around 15,000, primarily composed of Azerbaijanis and mountain Jews, alongside smaller communities of Russians and Armenians. The civil war in Russia also impacted Guba; in 1918, the city was occupied by the forces of the Baku Commune. A few months later, when the Turks took Baku, the authority of the Azerbaijan Democratic Republic spread to Guba. However, following the war, this territory ultimately became part of the USSR. The civil war significantly reshaped the region’s borders—had events unfolded differently, Azerbaijan could have easily acquired Derbent, while Russia, through Dagestan, might have claimed Guba.