In the Ilkhanate times, the Ispahbads of Gilan have had a principality on the borders of Gilan and Mughan, with a fortress and villages. In later times, a local Khan had his seat at Lankaran and was subject to the Persian monarchs. Peter the Great (), Emperor of Russia, first occupied the region during 1722–1732 and then it was returned to Safavid Persia. It was again occupied by Russia in 1796 and during the Russo-Persian War (1804–1813). In 1813 after the Storming of Lankaran most parts of the region were annexed by Russia and a smaller part remained within Persia. The Treaty of Gulistan of 24 October 1813, awarded to Russia the greater part of Talish, the part north of the Astara river.