In the last quarter of the 17th century, there was an economic and moral-ideological crisis in the Safavid state. The silk trade declined, the financial and monetary system collapsed, and during the reign of Shah Hussein (1694-1722) there were no precious metals in the country to cut money. Indian merchants dominated usury. At the time of the emergence of manufacturing and capitalist relations in Europe, there was a decline in the scientific and technological level in Azerbaijan. The ruling class led a lavish lifestyle, while the common people lived in poverty. As a result of great geographical discoveries, the direction of international trade routes changed, and sea routes, not caravan routes, began to play a major role.
In 1698-1701, taxes in the Safavid state were increased three times. Due to 7 years of drought in Azerbaijan, the famine began, as a result of which the population turned to armed uprisings.
In 1707-1711 a number of uprisings took place in Azerbaijan.
In 1721, a strong uprising broke out in Shirvan, and the ruler of Dagestan, Gazikumukhlu Surkhay khan, who used it, and the clergyman of Guba, Haji Davud, captured Shirvan. When the city of Shamakhi was captured, Russian merchants were killed.
Taking advantage of the decline of the Safavid state in 1722, the Georgians attacked Ganja, and the Afghan tribes revolted and captured the capital, Isfahan. Russia and the Ottoman Empire wanted to take advantage of the decline of the Safavid state.
Russia's first emperor, Peter I, was negotiating with Georgians and Armenians to gain a foothold in the South Caucasus. In South Caucasus politics, Russia viewed the Christian population as a bulwark.
The embassy, headed by Artemiy Volynsky, sent to the Safavid state of Russia in 1715-1718, was able to determine how deeply the Safavid state was in decline. Peter I planned to march to the Caspian regions.
In June 1722, 274 ships of the Russian navy and more than 100,000 ground troops began to march to the Caspian region. Excuse - to punish the criminals who killed Russian merchants in Shamakhi. The main reason is to capture Azerbaijani lands, especially those with access to the Caspian Sea.
August 1722 - The city of Derbent is captured by Russian troops. Peter I personally took part in the capture of the city. A 30,000-strong Georgian-Armenian army began marching in the direction of Ganja, but encountered resistance and returned to Tbilissi (Tbilisi).
July 1723 - The Russians, under the command of General Matyushkin, capture Baku as a result of heavy fighting. September 2, 1723 - According to the Treaty of St. Petersburg between Russia and Iran, the Caspian lands from Derbent to Gilan were to pass to Russia. However, Shah Tahmasib II did not ratify the treaty.
July-September 1723 - Ottoman troops begin marching on the South Caucasus. Ganja, Nakhchivan and Irevan were captured as a result of heavy fighting. June 27, 1724 - According to the Treaty of Istanbul between Russia and the Ottoman Empire, the Caspian provinces were to be included in the sphere of influence of Russia, all of Azerbaijan and all of Georgia.
November 10, 1724 - Peter I signed a decree on the resettlement of Armenians in the Caspian provinces, ie in Azerbaijan. Shah Tahmasib II (1722-1732) instructed Nadir khan Afshara to liberate the lands occupied by Russia and Turkey. Isfahan was liberated from the Afghans, Tabriz and Ardabil from the Ottomans.
1732 - The Treaty of Kermanshah is signed between the Safavid state and the Ottomans. According to the agreement, Shamakhi, Ganja, Irevan and Georgia remained with the Ottomans. The signing of the treaty reduced the king's prestige among the people.
1732 - According to the Rasht Treaty signed between Russia and the Safavids, the lands south of the Kura River were returned to the Safavids. 1732 - Nadir, taking advantage of the population's dissatisfaction with the shah, revolted, overthrew Tahmasib II, and proclaimed Abbas III shah. Nadir himself ruled the country as the king's deputy.
In 1733-1735, Nadir Khan liberated the entire South Caucasus from the Ottomans. The Ottomans, completely defeated in the battle of Echmiadzin in 1735, renounced their claims to Azerbaijan.
According to the Ganja Treaty signed between Nadir Khan and Russia on March 21, 1735, Russian troops left all the Caspian lands, including Baku and Derbent.
In February 1736, at the congress held in Mugan, the overthrow of Abbas III, the abolition of the Safavid state, and the proclamation of Nadir as "Nadir Shah Afshar" took place.
Taxes were increased to support Nadir Shah's marches in Central Asia and India. The Jizyah tax collected from the non-Muslim population was abolished. Steps have been taken to establish a navy in the Persian Gulf and the Caspian Sea. The increase in taxes, the arbitrariness of officials and the recruitment of civilians led to riots in some parts of Azerbaijan.
In 1738, during a revolt in the Tsar and Tala regions, Nadir Shah's brother Ibrahim khan was killed. In 1743, the revolt in Shirvan was led by Sam Mirza. These revolts were suppressed. Haji Chalabi led the Sheki uprising of 1743. This revolt resulted in the establishment of the Sheki khanate.