center at Ashir in 935 just south of Algiers. Although the 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 Almohad Caliphate in 1159, and in the 13th century came under the dominion of the Ziyanid sultans of the Kingdom 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. The Peñón of Algiers, an islet in front of Algiers harbour, had been occupied by the Spaniards as early as 1302. Thereafter, a considerable amount of trade began to flow between Algiers and Spain. However, Algiers continued to be of comparatively little importance until after the expulsion of the Moors from Spain, many of whom sought asylum in the city. In 1510, following their occupation of Oran and other towns on the coast of Africa, the Spaniards fortified the islet of Peñon and imposed a levy intended to suppress the Barbary pirates. Ottoman rule In 1516, the amir of Algiers, Selim b. Teumi, invited the corsair brothers Oruç Reis and Hayreddin Barbarossa to expel the Spaniards. Oruç Reis came to Algiers, ordered the assassination of Selim, and seized the town and ousted the Spanish in the Capture of Algiers (1516). Hayreddin, succeeding Aruj after the latter was killed in battle against the Spaniards in the 1518 fall of Tlemcen, was the founder of the pashaluk, which subsequently became the beylik, of Algeria. Barbarossa lost Algiers in 1524 but regained it with the 1529 Capture of Peñón of Algiers, and then formally invited the Sultan Suleiman the Magnificent to accept sovereignty over the territory and to annex Algiers to the Ottoman Empire. Algiers from this time became the chief seat of the Barbary pirates. In October 1541 in the Algiers expedition, the King of Spain and Charles V, Holy Roman Emperor sought to capture the city, but a storm destroyed a great number of his ships, and his army of some 30,000, chiefly made up of Spaniards, was defeated by the Algerians under their pasha, Hassan. Formally part of the Ottoman Empire but essentially free from Ottoman control, starting in the 16th century Algiers turned to piracy and ransoming. Due to its location