Melilla was initially jointly administered by the House of Medina Sidonia and the Crown, and a 1498 settlement forced the former to station a 700-men garrison in Melilla and forced the latter to provide the city with a number of maravedíes and wheat fanegas. The Crown’s interest in Melilla decreased during the reign of Charles V. During the 16th century, soldiers stationed in Melilla were badly remunerated, leading to many desertions. The Duke of Medina Sidonia relinquished responsibility over the garrison of the place on 7 June 1556.
During the late 17th century, Alaouite sultan Ismail Ibn Sharif attempted to conquer the presidio, taking the outer fortifications in the 1680s and further unsuccessfully besieging Melilla in the 1690s.
The current limits of the Spanish territory around the Melilla fortress were fixed by treaties with Morocco in 1859, 1860, 1861, and 1894. In the late 19th century, as Spanish influence expanded in this area, the Crown authorized Melilla as the only center of trade on the Rif coast between Tetuan and the Algerian frontier. The value of trade increased, with goat skins, eggs and beeswax being the principal exports, and cotton goods, tea, sugar and candles being the chief imports.
Melilla’s civil population in 1860 still amounted for only 375 estimated inhabitants. In a 1866 Hispano-Moroccan arrangement signed in Fes, both parts agreed to allow for the installment of a customs office near the border with Melilla, to be operated by Moroccan officials. The Treaty of Peace with Morocco that followed the 1859–60 War entailed the acquisition of a new perimeter for Melilla, bringing its area to the 12 km2 the autonomous city currently stands. Following the declaration of Melilla as free port in 1863, the population began to increase, chiefly by Sephardi Jews fleeing from Tetouan who fostered trade in and out the city. The first Jews from Tetouan probably arrived in 1864, meanwhile the first rabbi arrived in 1867 and began to operate the first synagogue, located in the Calle de San Miguel. Many Jews arrived fleeing from persecution in Morocco, instigated by Roghi Bu Hamara. Following the 1868 lifting of the veto to emigrate to Melilla from Peninsular Spain, the population further increased with Spaniards. The Jewish population, who also progressively acquired Spanish citizenship, increased to 572 in 1893. The economic opportunities created in Melilla henceforth favored the installment of a Berber population.
The first proper body of local government was the junta de arbitrios, created in 1879, and in which the military used to enjoy preponderance. The Polígono excepcional de Tiro, the first neighborhood outside the walled core (Melilla la Vieja), began construction in 1888.
The turn of the new century saw however the attempts by France (based in French Algeria) to profit from their newly acquired sphere of influence in Morocco to counter the trading prowess of Melilla by fostering trade links with the Algerian cities of Ghazaouet and Oran. Melilla began to suffer from this, to which the instability brought by revolts against Muley Abdel Aziz in the hinterland also added, although after 1905 Sultan pretender El Rogui (Bou Hmara) carried out a defusing policy in the area that favored Spain. The French occupation of Oujda in 1907, compromised the Melillan trade with that city. and the enduring instability in the Rif still threatened Melilla. Between 1909 and 1945, the modernista (Art Nouveau) style was very present in the local architecture, making the streets of Melilla a “true museum of modernista-style architecture”, second only to Barcelona (in Spain), mainly stemming from the work of prolific architect Enrique Nieto.