In 1795, Alexander led a Georgian contingent dispatched to help the allied Ibrahim Khalil Khan of Karabakh against the Iranian encroachment. In June, the allies fought back a 20,000-strong force sent by Agha Mohammad Khan Qajar against Karabakh. Back in Georgia, in July 1795, Alexander raised a force of Turkic mercenaries brought from Karabakh against the anticipated Iranian advance. Fighting by his father's side, Alexander witnessed the sack of Tiflis in a disastrous attack by Agha Mohammad Khan Qajar, who resented Heraclius's rapprochement with the Russian Empire and demanded Georgia's reversal to traditional allegiance to Iran. Disappointed by his failure, Heraclius, then over 75, retired to his native Telavi, leaving Alexander in charge of restoring Tiflis.