The Graciosa fortress was established on the coast of Morocco by the Portuguese in 1489. It was established on a small river island, about three leagues from the sea, at the junction of river Lucus (Wadi Lukkus) and river el-Mekhazen (Oued Makhazine), a few kilometers inland from modern Larache. The island had been yielded to the Portuguese by Abu Zakariya Muhammad al-Saih al-Mahdi through a treaty following the Portuguese capture of Arzila.
The fortress was built from February 1489 by Gaspar Jusarte. In May, a second fleet led by D. Pedro de Castelo Branco reached the island, and Diogo Fernandes de Almeida was named governor.
Abu Zakariya Muhammad al-Saih al-Mahdi attacked the island to dislodge the Portuguese. After the Moroccan had blocked the river with trees, the Portuguese in Graciosa fortress had to capitulate. By the Treaty of Xamez, signed on August 27, 1489, they evacuated the island. The Portuguese thus did not resist long in Graciosa, and the Moroccans soon founded Larache at the mouth of the river.
Altogether, the Portuguese are documented to have seized 6 Moroccan towns, and built 6 stand-alone fortresses on the Moroccan Atlantic coast, between the river Loukos in the north and the river of Sous in the south. Four of these stand-alone fortresses only had a short duration: Graciosa (1489), São João da Mamora (1515), Castelo Real of Mogador (1506-10) and Aguz (1520-25). Two of them were to become permanent urban settlements: Santa Cruz do Cabo de Gué (Agadir, founded in 1505-06), and Mazagan (Mazagão) founded in 1514-17. The Portuguese had to abandon most of their settlements between 1541 and 1550, although they were able to keep Ceuta, Tangier and Mazagan.