 Realizing what was going to happen to himself, Mostafa Khan fled to mainland Iran in 1820 with his son; Yermolov did not waste any time to annex the Shirvan Khanate.Several years later, in violation of the Gulistan treaty (1813), the Russians invaded Iran's Erivan Khanate.This sparked the final bout of hostilities between the two; the Russo-Iranian War of 1826-1828.