The harbour became part of numerous Spanish possessions on the coast of the Maghreb, which had been captured since 1496: In 1516, Mostaganem was seized by Hayreddin Barbarossa from his base of Algiers.
He was at the head of an army of 10 to 11,000 men[8][9] partly inexperienced (he had received authorization to recruit 8,000) to which are added the 1,200 experienced soldiers from the place of Oran and artillery, some field and siege guns.
A sergeant then launched the assault which was stopped dead on the orders of Martín Alonso Fernández who stubbornly undertook a regular siege.
[13][12] When all the troops were gathered, a camp was set up on the heights out of reach of the defenders and the defense was prepared by digging a ditch and installing a field battery[13] while the armies of Tlemcen and Algiers converged on a forced march towards the Spanish position.
[18] Around 3 p.m., another terrible event struck the Spaniards; the fire blew up barrels of gunpowder and killed several hundred men, including Army Major-General Navarrete.
[22] His son Don Martín de Córdoba, the future Governor of Oran, was also captured and was imprisoned as a Christian slave in Algiers under the beylerbey Hasan Pasha, until he was exchanged for a huge ransom of 23,000 escudos.
[23][25] This battle put an end to the governorship of Oran by count Martín Alonso Fernández, and definitively closed a period when Spain intervened in the Oranian region's affairs.
The Spaniards therefore renounced major land expeditions in western Algeria and concentrated on maintaining their positions in Oran and Mers el-Kébir.
Henceforth the whole coast escaped their grasp; the ports of Bône, Béjaïa, Cherchell, Ténès and Mostaganem served as bases for the Ottoman Algerian navy.
[28] The battle of Mostaganem was celebrated in Algerian popular songs through the works of the saint and poet Sidi Lakhdar ben Khlouf.