After the death of Iranian ruler Nader Shah (r. 1736-1747), several khanates were established on the territory that constitutes the present-day Republic of Azerbaijan.
The first capital of the khanate was the Bayat Castle built in 1748 in Kebirli mahali (province).
It included all strategic defense structures such as walls warfare trenches and had a market, bath house and a mosque.
The capital was therefore soon moved to the newly constructed Shahbulag Castle located in lowland Karabakh in 1752.
[citation needed] Eventually, with an intent to secure the entity from external threats, especially from Iran, Panah Ali Khan moved the capital to its final location, Shusha, a more reliable natural fortress located on a hardly penetratable mountain rock.