1492 was a very good time to start learning Spanish. Hispanics had gained control of the whole peninsula, the discovery of the Americas was just around the corner and the country was looking to expand.
There was only one natural way they could go: south. Also, the newly-formed reign had shown the foresight of signing an agreement with Portugal called the Treaty of Alcáçovas which, for better or worse, divided the world into future Spanish or Portuguese conquests.
It was decided that Africa should be the place to go.
Spain's relationship with Africa had started in 1402, when they had changed Canary Island history by turning them into a colony. But now Spain wanted Melilla.
Two captains called Lezcano and Lorenzo Zafra were sent to the coast of Africa to pick an invasion-friendly location, and came back with nothing but good words about the place's geography. It was decided that a break was needed after all the effort of unifying a whole country and finishing the job of kicking the Muslims out of the Peninsula, which the king's ancestors 300 years prior couldn't finish. Small, accessible, defenseless Melilla, right in the North of Africa, was perfect for the occasion, and the conquest of Melilla was practically a plan.
There was, however, a problem. The Treaty of Alcáçovas stipulated that Melilla was in Portugal's area of influence. Right then, Christopher Columbus returned with stories of a new land, something called the Americas (back then, though, they used to think it was the Indias, but that's another story). This changed everything.
The Treaty of Alcáçovas was now outdated and the just-enlarged world had to be divided again. The negotiation took place in Tordesillas in 1494, and led to the now-famous Treaty of Tordesillas, also known as how the world was seen in the Peninsula back in their time.
The treaty of Tordesillas basically divided the world again, using Spain and Portugal's criteria. It established which parts of the world could be conquered by Spain and which parts by Portugal, hardly considering England and France in their plans, just like other countries preferred to ignore them altogether.
In the renegotiation, Spain was sure to claim Melilla for itself. With the treaty of Tordesillas signed and official, they decided not to waste any more timr and headed straight for their new objective. They sent a ship commanded by a man called Pedro de Estopinan. He was the duke of Medina Sidonia, and therefore had good relations with the monarchs, who blessed him in his quest to expand their country.
The ship sailed from Gibaltrar. The conquest of Melilla had begun.
The conquest was fated to end very soon afterwards. Pedro de Estopinan reached the Moroccan coastline that same year on September 17th. He essentially claimed Melilla as his.
If he found any resistance, it must have been some peskily strong African headwind. Everything else just surrendered to him. Melilla became the most exotic Spanish summer camp ever.
Thus, Melilla became a domain of the Duke of Medina Sidonia (a small village located near Cadiz). It would be annexed to Spain in 1556 and suffer a series of sieges when the locals realized they were not their own masters anymore. The first one started in 1562 and it went on to become the longest one in Melilla's history: it went on for three years, until 1565.
It would be under siege six more times. Since the conquest of Melilla, its belonging to Spain remains, to this day, a source of light tension to some of its inhabitants.