The Supreme Court of Spain ruled that the country's authorities acted illegally in 2021 when they returned unaccompanied migrant children to Morocco.
Hundreds of unaccompanied minors were among the approximately 10.000 people who jumped over the border fence and tried to enter Ceuta, a Spanish exclave in northern Africa.
Spain is required by law to care for minor migrants until their relatives are located or until they turn 18.
Spain's interior ministry defended its action by saying the children wanted to go home.
Spanish officials denied accusations by human rights groups that this violated international law.
Authorities cited a 2007 agreement between Spain and Morocco to assist in the return of children once their cases are considered.
However, Supreme Court judges rejected those arguments, saying that Spanish law prevailed and that the mass return of children was in violation of the European Convention on Human Rights.
More than tens of thousands of migrants from sub-Saharan countries try to reach Spain every year in boats that depart from the coast of northwestern Africa.
Most reach the Canary Islands in the Atlantic Ocean, while others try to cross the Mediterranean Sea to Spain or jump the fence in Ceuta. Those roads are often dangerous and unsafe, so thousands of them die.
Bonus video: