The present city was founded in 944 by Bologhine ibn Ziri, the founder of the Berber Zirid dynasty.  He had earlier (935) built his own house and a Sanhaja center at Ashir, just south of Algiers.  Although his Zirid dynasty was overthrown by Roger II of Sicily in 1148, the Zirids had already lost control of Algiers to their cousins the Hammadids in 1014. The city was wrested from the Hammadids by the Almohads in 1159, and in the 13th century came under the dominion of the Ziyanid sultans of Tlemcen. Nominally part of the sultanate of Tlemcen, Algiers had a large measure of independence under Thaaliba amirs of its own due to Oran being the chief seaport of the Ziyanids.