According to Clifford Edmund Bosworth, "Hamedan is a very old city. It may conceivably, but improbably, be mentioned in cuneiform texts from ca. 1100 BC, the time of Assyrian King Tiglath-pilesar I, but is certainly mentioned by Herodotus (i.98) who says that the king of Media Diokes built the city of Agbatana or Ekbatana in the 7th century BC."
Hamedan was established by the Medes and was the capital of the Median empire. It then became one of several capital cities of the Achaemenid Dynasty.
Hamedan is mentioned in the biblical book of Ezra as the place where a scroll was found giving the Jews permission from King Darius to rebuild the temple in Jerusalem. (Ezra 6:2). Its ancient name of Ecbatana is used in the Ezra text. Because it was a mile above sea level, it was a good place to preserve leather documents.
During the Parthian era, Ctesiphon was the capital of the country, and Hamedan the summer capital and residence of the Parthian rulers. After the Parthians, the Sassanids constructed their summer palaces in Hamedan. In the year 633 the battle of Nahavand took place and Hamedan fell into the hands of the Muslim Arabs.
During the Buwayhids, the city suffered much damage. In the 11th century, the Seljuks shifted their capital from Baghdad to Hamedan. The city of Hamedan, its fortunes following the rise and fall of regional powers, was completely destroyed during the Timurid invasion. During the Safavid era, the city thrived. Thereafter, in the 18th century, Hamedan was surrendered to the Ottomans, but due to the courage and chivalry of Nader Shah e Afshar, Hamedan was cleared of invaders and, as a result of a peace treaty between Iran and the Ottomans, it was returned to Iran. Hamedan stands on the Silk Road, and even in recent centuries the city enjoyed strong commerce and trade as a result of its location on the main road network in the western region of Persia and Iran.
During World War I, the city was the scene of heavy fighting between Russian and Turko-German forces. It was occupied by both armies, and finally by the British, before it was returned to control of the Iranian government at the end of the war in 1918.