After the Assyrian empire ravaged Elam, in the north a new nation formed out of a conglomerate of peoples in the country. This was in part due to the Assyrian threat. The origins of the Medes and Persians is still unconfirmed and under debate. One school of thought tends to the theory that they migrated from southern Russia; another proclaims that they developed locally in Iran. It is this authors view that they developed locally. For more info click here
Under their leader Dayaukku, in the 8th century BC
the Medes unsuccessfully rebelled against the Assyrians.
However they did manage to establish the a government
under him. Previously the Medians
were divided into local villages and settlements ruled by
local chieftains. The fight with Assyria brought
these settlements together. The army though not successful
learned many tactics. The median army, who had a greater cavalry
than Assyria, but a weaker infantry and chariot-men learned to
manuveur on the battlefield. They often retreated into the mountains
were the Assyrians could not operate their infantry. Another tribal
leader Khshathrita brought the Median tribes together and ousted the
Assyrians and took some land.According to Assyrian anals he subjugated the Persians and other Iranid groups in the Zagros mountains, beckoning war with Assyria. He was later killed by Scythian tribes. For a period of about 25 years the Scythians maintained lordship over the Medes and Persians.
Then Khshathrita's son Huvakhshtra (Cyaxares), took control ousting the Scythians and, in alliance with the Chaldeans (Huvakhshtra's grand daughter was given in marriage to the Babylonian prince) , took control of a large portion of land including most of Iran, the Caucasus, and Eastern Anatolia. These kingdoms were semi-autonomous, having kings who in turn payed tribute to their Median overlords.
Upon his death his son Astyages took control. However his reign
marked the decline of the Median empire and its eventual collapse,
to be eventually taken by Cyrus the Great.