Quba Khanate
The smaller Old Shamakhi Khanate continued to exist under brothers Muhammad Said khan and (1748—1786) Aghasi Khan until the two killed Hajji Muhammed Ali Khan and united two khanates. After the merge, the New Shamakha was finally abandoned, and the old town rebuilt in 1786. During 1768—1789 the Shirvan khanate was occupied by the much stronger Quba Khanate and Shaki Khanate. Aghasi Khan was blinded and Muhammad Said Khan was taken captive to Derbent.