The agents suffered bruises and scratches that required medical care when they tried to detain the migrants who arrived at the San Lorenzo beach near Melilla's marina on a wooden boat, the local Spanish government delegation said in a statement.
Police detained five migrants but the remaining ten managed to escape and entered the Spanish enclave on the northwestern African coast, it added.
Melilla, which is home to around 80,000 people, is surrounded by Morocco on one side and the Mediterranean Sea on the other.
Migrants from across Africa seeking to get to Europe camp out around Melilla and then make late night assaults on a metal border fence separating the enclave from Morocco or try to enter the territory by boat.
Spain reinforced the border fence separating Melilla from Morocco in August after a resurgence of crossing attempts.
Melilla and Ceuta, another Spanish enclave perched on the coast of north Africa, are both claimed by Morocco.