The legal action against the border jumpers comes after about 2,000 migrants took part in the attempt, triggering violent skirmishes with Moroccan security forces and Spanish border guards at the Melilla enclave, with about 100 managing to get across.
Moroccan authorities said the at least 23 deaths resulted from a crush after what they called a stampede, and from migrants falling from a high fence. Scores more were injured, they said, along with dozens of Moroccan security personnel.
The independent NGO Moroccan Association of Human Rights (AMDH) organization said 29 migrants had died, citing unnamed hospital sources.
Video AMDH issued of the aftermath of Friday's disaster showed dozens of African men lying piled alongside each other, many apparently lifeless, some bleeding and some making feeble movements while Moroccan police stood over them.
AMDH said the injured were left unattended for hours, adding to the death toll. Some of the footage showed Moroccan security officers striking men lying on the ground.
Moroccan authorities shared their own footage of the border storming with African ambassadors, an official source said, including police efforts to clear migrant camps from forest areas near the enclave before the raid.
It showed a very large group of migrants storming the fence using sticks and throwing rocks as they clashed with security guards who used tear gas to try to disperse them.
At one point, a section of fence collapsed under a large group trying to climb over it, with many falling several meters.
The official source said the cause of the crush was a concentration of migrants trying to breach a particularly narrow gateway at the border crossing.
On Sunday, the African Union voiced shock at what it called the violent treatment of migrants leading to deaths and injuries, and demanded an immediate investigation. Morocco and Spain have denied using excessive force.
The judicial source said most of those being prosecuted are from Sudan and that they face charges of igniting fires, attacking security forces and facilitating illegal border crossings.
AMDH said three of its lawyers would help represent the migrants in court.
Many other migrants detained by the authorities on Friday have been bussed to southern Morocco and released there, AMDH said, a practice Rabat began in 2018 to discourage illegal migration attempts.
The United Nations on Tuesday called for an independent investigation into the Melilla fence deaths.
Your browser doesn’t support HTML5
"We call on the two countries to ensure an effective and independent investigation is held as a first step towards establishing the circumstances of the deaths and injuries, and any possible responsibilities," UN rights office spokeswoman Ravina Shamdasani told reporters in Geneva.
She added that the probe should seek to "ensure that accountability is guaranteed as appropriate".