In 1516, the amir of Algiers, Selim b. Teumi, invited the corsair brothers Aruj and Hayreddin ''Barbarossa'' to expel the Spaniards. Aruj 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 Fall of Tlemcen (1517), was the founder of the ''pashaluk'', which subsequently became the ''beylik'', of Algeria. Barbarossa lost Algiers in 1524 but regained it with the Capture of Algiers (1529), and then formally invited the Sultan Suleiman the Magnificent to accept sovereignty over the territory and to annex Algiers to the Ottoman Empire.