The arrival of nearly 2,000 mostly sub-Saharan African refugees and migrants at Spain's Melilla enclave has resulted in the highest death toll of refugees and migrants at the border in years.

Many migrants and refugees are detained by police officers on Spanish soil after crossing the fences separating the Spanish enclave of Melilla from Morocco.
Many migrants and refugees are detained by police officers on Spanish soil after crossing the fences separating the Spanish enclave of Melilla from Morocco. (AP)

The death toll following a mass attempt by a large crowd of African refugees and migrants to cross from Morocco into Spain's Melilla enclave has climbed to 23, according to Moroccan officials.

Some 2,000 refugees and migrants approached Melilla at dawn on Friday and over 500 managed to enter a border control area after cutting a fence with shears, the Spanish government's local delegation said in a statement.

Moroccan officials said late Friday that the deaths were a result of injuries sustained in the attempt to cross.

"Some fell from the top of the barrier" separating the two sides, a Moroccan official said, adding that 140 security personnel and 76 refugees and migrants were injured during the attempt to cross.

The Spanish government's local delegation said only that 49 Spanish police officers were lightly injured.

Morocco had deployed a "large" number of forces to try to repel the refugees and migrants on the border, who "co-operated actively" with Spain's security forces, it said earlier in a statement.

However, footage geolocated by the New York Times showed security forces using indiscriminate force and footage shared across Twitter showed a violent crackdown by Moroccan and Spanish police at the border with audible gunshots.

Images on Spanish media showed exhausted people laying on the pavement in Melilla, some with bloodied hands and torn clothes.

Speaking in Brussels, Spanish Prime Minister Pedro Sanchez condemned the attempted crossing, calling it a "violent assault" which he blamed on "mafias who traffic in human beings".

READ MORE: Spain's borders with North Africa will remain closed

Concern and calls for investigations
Melilla and Ceuta, Spain's other tiny North African enclave, have the European Union's only land borders with Africa, making them attractive for crossings.

The International Organization for Migration and the UN refugee agency expressed "grave concern at the lives lost and the number of injured".

The agencies reminded member states of the "need in all circumstances to prioritise the safety of migrants and refugees, to avoid excessive use of force and to respect their fundamental rights."

The Moroccan Association for Human Rights (AMDH) demanded a "comprehensive, quick and serious enquiry", while the Democratic Labour Organisation (ODT) trade union urged the government "to investigate this tragedy and do what is needed" both for migrants and police.

It was the first such mass crossing attempt since Spain and Morocco mended diplomatic relations last month and the death toll is by far the worst recorded in years of attempts by migrants to cross into Melilla.

In Spain, Sanchez's left-wing coalition partner Podemos also called for a probe.

Spain will seek to have "irregular migration" listed as one of the security threats on NATO's southern flank when the alliance gathers for a summit in Madrid on June 29-30.

READ MORE: Spain: Dozens of asylum seekers dead or missing after dinghy capsizes