It is the first such mass crossing incident since Spain and Morocco mended diplomatic relations last month.
Over 2,000 migrants stormed the border between the Moroccan city of Nador and Melilla on Friday, with 133 people successfully breaching the fence, according to officials.
“A large group of sub-Saharans [Africans]…broke through the access gate of the Barrio Chino border checkpoint and entered Melilla by jumping over the roof of the checkpoint,” the Spanish government’s delegation in the area said in an earlier statement.
“All of them [are] men and apparently adults,” it added.
The migrants arrived at the crossing at about 6am and the crossing took place after a skirmish at about 8.40am.
A spokesperson for the Spanish government’s office in Melilla said the crowd was stopped by Spanish civil guard police and Moroccan forces on either side of the border fence. This led to clashes with security forces.
Morocco’s interior ministry initially said five migrants had died in the border raid, some after falling from the fence surrounding Melilla and others in a crush, and that 76 migrants were injured.
It later said another 13 had died in hospital from the injuries sustained.
The Moroccan Human Rights Association reported 27 dead but the figure could not immediately be confirmed.
Some 140 Members of the Moroccan security forces were also injured, it added, five seriously, though none of them died. Four police vehicles were damaged by rocks thrown by some migrants.
Those who successfully made it to the other side of the border were taken to a local migrant centre, where authorities were evaluating their circumstances. Images on Spanish media showed exhausted refugees and migrants laying on the pavement in Melilla, some with bloodied hands and torn clothes.
Friday’s crossings were the first attempt since relations between Spain and Morocco improved in March after a year-long dispute centred on Western Sahara, a former Spanish colony annexed by Morocco in 1976.
The migrants, most of whom flee due to poverty and violence in their local areas, often make such mass attempts to cross through the border onto the Spanish territories in North Africa.
Earlier in March, more than 3,500 people tried to scale the six-meter barrier that surrounds Melilla and nearly 1,000 made it across, according to Spanish authorities.
Additional reporting by agencies