A total of 209 people from sub-Saharan Africa seeking to get to Europe forced their way across the fence in the afternoon, the central government's representative office in Melilla said in a statement.
The police officer who was injured was “attacked by an immigrant with one of the hooks they use to clamber up the fence” as he tried to stop them, the statement said, adding the implement cut his earlobe.
In order to get across, migrants often use hooks and shoes studded with nails.
Four of the migrants, meanwhile, were sent to hospital for minor injuries, it added.
Mobile phone footage broadcast by Spanish media showed a group of migrants running through the streets of the city.
They have since been taken to a migrant detention centre.
The barrier is composed of two six-metre-high (20-feet-high) fences, with criss-crossing steel cables in between.
Melilla and Ceuta, another Spanish enclave nearly 400 kilometres (250 miles) away on the north coast of Africa, are often used as entry points into Europe for African migrants.
They have the only two land borders between Africa and the European Union.
Over the years, thousands of migrants have attempted to cross the 12-kilometre (7.5 mile) frontier between Melilla and Morocco, or the eight-kilometre border at Ceuta, by climbing the border fences, swimming along the coast or hiding in vehicles.
Spain is increasingly targeted by people desperate to reach Europe from Africa, with the number of migrants reaching the country in 2017 hitting a record high of nearly 22,900, according to EU border agency Frontex.
This was more than double the previous record set in 2016