At the age of six Agha Muhammad was castrated on the orders of 'Adil Shah to prevent him from becoming a political rival, but this disability did not hinder his career. Despite being a eunuch, he became the chief of his tribe in 1758. In 1762 he was captured by a rival tribe and sent to Shiraz as a prisoner to Karim Khan's court. Agha Muhammad spent the next 16 years as a hostage, until he escaped in 1779. That same year, the death of Shah Karim Khan Zand plunged the country into a series of civil wars and disputes over the succession, with many members of the Zand dynasty acceding to the Peacock Throne in the space of only ten years. Agha Muhammad took the opportunity to launch a rebellion which, in 1794, succeeded in capturing Lotf Ali Khan, the last Zand ruler. Two years later he proclaimed himself Shahanshah (King of Kings).
Agha Muhammad restored Persia to a unity it had not had since the fall of the Safavid dynasty. He was, however, a man of extreme violence who killed almost all who could threaten his hold on power. In 1795 he ravaged Georgia, a kingdom to the north of Persia, which was formerly part of the Safavid empire. In the same year he also captured Khorasan. Shah Rukh, ruler of Khorasan and grandson of Nadir Shah, was tortured to death because Agha Muhammad thought that he knew of Nadir's legendary treasures.
In 1796 Agha Muhammad moved his capital from Sari to Tehran. He was the first Persian ruler to make Tehran, then only a village, his capital. Although the Russians took Derbent and briefly occupied Baku during the Persian Expedition of 1796, he successfully expanded Persian influence into the Caucasus, reasserting Iranian sovereignty over its former dependencies in the region. He was, however, a notoriously cruel ruler, who reduced Tbilisi to ashes and massacred its Christian population, as he had done with his Muslim subjects.
Agha Muhammad was assassinated in 1797 in the city of Shusha, the capital of Karabakh khanate, after about 16 years in power. Legend has it that at the night of his death, Agha Muhammad Khan ordered his servants to bring him a melon cut into slices. He finished half, ordered the other half to be put away and vowed to his servants, that if even one slice of the melon was missing in the morning, all three servants would be beheaded by him. Later on that night one of the servants forgot and ate a slice. The servants then killed Agha Muhammad Khan with the dagger because they were afraid he would kill them in the morning.