After Granada fell in southern Spain, in the 1490's, North Africa was considered for the next stage of the "crusade."
Mers-el-Kebir and Oran sent envoys to the court and tried to establish good relations with Castille and Leon. The Portugese were in Ceuta since 1415.
Melillia was taken in 1497 by Medina-Sidona (a powerfull Spanish Duke). In 1505 Malaga was taken, then Mers-el-Kebir. Oran was taken in 1509. Bougie was taken in 1510.
Algiers accepted Spanish rule in 1510. Tripoli was captured in 1510.
In 1515 Spain defended Bougie with 3,000 men from Barbarossa. Seems like Khayr-al-Din/Barbarossa took Algiers away this year also (might be 1529.)
The Turks penetrated into Germany in the next 10 years and fighting was redirected to the German states.
In 1522 Barbarossa recaptured Velez de La Gomera, and the Penon Algiers in 1529. The Castillian garrison there was put to death.
La Goletta was sieged, taken and sacked by the Spanish in 1535. Tunis was also captured and Barbarossa fled.
In 1541 Spain attempted to attack Algiers from the sea. A storm blew up and 150 vessels, many small, and 12,000 men were lost. Included was the loss of 13 or 14 large galleys.
In 1552 Tlemcen was taken over by the Ottomons. In 1555, Bougie was recaptured by the Ottomons.
In 1558, an independant Spanish expedition to North Africa was wiped out.