The Mehranids returned to prominence in the 12th century, when their lands were part of Bagratid Media. For many years Rey was in the frontier region between the Bagratids and the Mongols, and the Mehranids built up a formidable army to oppose the frequent Mongol raids across the border. After the Arbela campaign of 1255, in which the Mongols overran the eastern Bagratid lands before withdrawing, the Mehranids came to rule over Media itself, and expanded in the following years to fill the political vacuum as their neighbours weakened.
At its height, the Mehranid Empire stretched from Assyria in the west to the Hindu Kush in the east. It fought the Chagatai Khanate for many years over the control of central Asia, eventually attracting the Chagataid warlord Timur to its side.
In 1582 Ahmad Shapur Shah converted to Islam, which was already prevalent among the western portions of the empire. In response, many of the Buddhist and Zoroastrian feudal lords of the east rose up against him, including the Peshdadids of Khorasan. By 1585 the Peshdadids had overthrown the Mehranids and captured the throne of Persia, restoring Zurvanism as the state religion, while Ahmad Shapur fled into exile in Romania.