About 260 migrants tried to storm the barbed wire fence which separates the territory from Morocco but Spanish security forces prevented all but 53 of them from entering Melilla, Guardia Civil police force chief Jose Manuel Santiago said.
“They used metal hooks in their attempt and threw rocks at police,” he told a news conference.
An officer was lightly injured and two migrants arrested, the central government's representative in Melilla said in a statement.
The incident comes with Spain under nationwide lockdown to prevent the spread of the novel coronavirus. Thousands of police have been deployed to enforce the ban on the movement of people.
“We will continue to work with Morocco to avoid this type of situation, we will not let down our guard,” Santiago said when asked if the lockdown had affected border security.
Spain's two North African enclaves, Melilla and Ceuta, are the European Union's only land borders with Africa.
Hundreds of migrants camp out for weeks and months in Moroccan territory just outside of both territories preparing to try to scale the border fences or, occasionally to swim along the coast.
During the first three months of 2020, 1,140 migrants managed to enter the enclaves overland, a 16 percent drop over the same period last year, according to Spanish interior ministry figures.