The Conquest of Melilla occurred in September 1497, when a fleet sent by the Duke of Medina Sidonia  seized the north African city of Melilla., as continuation of Reconquest of Mauritania Tingitana During the 15th century the mediterranean cities of the Sultanate of Fez  fell in decadence in opposition to cities located in the Atlantic facade, which concentrated most of the economic activity. By the end of the 15th century, the port of Melilla, that had been often disputed between the rulers of Fez and Tlemcen, was nearly abandoned. Plans for the conquest occurred as soon as the Fall of Granada in 1492. Spanish captains Lezcano and Lorenzo Zafra visited the coast of Northern Africa to identify possible locations for the Spanish to overtake, and Melilla was identified as a prime candidate. Melilla was, however, in the Portuguese zone of influence under the terms of the 1479 Treaty of Alcáçovaz. At Tordesillas in 1494, King John II of Portugal, the Portuguese ruler agreed to make an exception and permitted the Spanish to attempt the conquest of Melilla. The duke sent Pedro Estopiñán  who conquered the city virtually without a fight in 1497, as internal conflicts had depleted it of troops, and its defenses were weakened. The Wattasid ruler Muhammad al-Shaykh sent a detachment of cavalrymen to retake control of the city, but they were repulsed by the guns of the Spanish ships.
Question: Which occurred first, the Treaty of Alcáçovaz, or the conquer of Melilla?
Answer: Treaty of Alcáçovaz