The siege of Baghdad (May-9 July 1401) was one of Tamerlane's most destructive victories, and saw the city virtually destroyed after it was taken by storm at the end of a forty day long siege.
Before Tamerlane appeared on the scene Baghdad had been the summer residence of Sultan Ahmad Jalayir, the Jalayirid ruler of western Persia. The city first fell to Tamerlane in the summer of 1393, surrendering without a struggle after Sultan Ahmad fled the city. Tamerlane appointed a governor to rule the city, but he was unable to defend it when Sultan Ahmad reappeared in 1394. Ahmad was able to maintain a precarious hold on the city for the next few years, despite a conspiracy against him in 1397-98 and a threatened attack by Miran Shah in 1398, but in 1400 Tamerlane himself returned to campaign in Anatolia and Syria. Correctly assuming that Tamerlane would next turn south to attack Baghdad Ahmad gave command in the city to Amir Faraj, one of his generals, and then fled into exile with the Ottomans.
By the spring of 1401 Tamerlane had reached Mosul, and in May he sent part of his army from there towards Baghdad. This force was defeated by a mixed army of Turkmen and Bedouin, under the command of Amir Faraj. Tamerlane sent reinforcements, and when they failed to take the city, arrived in person to conduct the siege. The defenders held out for forty days before Tamerlane decided to storm the city. The final attack came on 9 July 1401, and was followed by a brutal sack of the city in which every inhabitant was killed. The only exceptions were religious figures, who Tamerlane always spared. The city's fortifications and public buildings (again excluding mosques, hostels and universities) were destroyed.
Tamerlane didn't retain control of the city for very long. Sultan Ahmad returned to the city soon after Tamerlane left, only to be expelled by one of his former allies. Tamerlane's grandson Aba Bakr retook the city in 1403, but Sultan Ahmad returned again after Tamerlane's death, only to be finally defeated and exectured by his Turkmen allies in 1411.