In the 11th century, the Seljuk dynasty and the Zengid dynasty fought wars with the Kurdish emirates. The Seljuk dynasty took control of Iran, Iraq, and Anatolia. The Zengid dynasty controlled the lands around Mosul for the Seljuks. The success of their armies ended the independence of the Kurds' emirates. When the Seljuks took control of Dvin (now in Armenia) from the Shaddadid dynasty, Shadhi ibn Marwan and his two sons Najm ad-Din Ayyub and Asad ad-Din Shirkuh worked for the Shaddadids. They went away from the city and came to Iraq. Najm ad-Din Ayyub and Asad ad-Din Shirkuh became important soldiers in the armies of Nur ad-Din Zengi, who controlled Syria and Mosul. Najm ad-Din Ayyub became governor of Baalbek and Damascus. Asad ad-Din Shirkuh became governor of Homs.