In the mid-18th century, the whole of Karabakh became a semi-independent khanate called the Karabakh Khanate which lasted for about 75 years. The Russian Empire advanced into the region in 1805, declared Artsakh a Russian protectorate and formally annexed it from Iran in 1813 according to the Treaty of Gulistan. The Armenian princes lost their status as princes (''meliks'') in 1822.