One gang allegedly charged about €2,000 ($2,300) to smuggle a minor by boat from Morocco, a price that would rise to up to €8,000 if weather conditions were bad, Spanish police said in a statement.
The group charged €5,000 to bring minors across on a jet ski and €2,500 hidden inside trucks on ferries. It is suspected of having smuggled over 100 migrants into Spain from Morocco.
Spanish police said they had broken up the group with the arrest of 22 people across the country, including three employees of a youth detention centre in the northern region of Asturias suspected of helping the minors get documents to be able to live in Spain legally.
The authorities said they began their investigation after detecting a significant rise in the arrival of unaccompanied minors from Morocco at this youth detention centre, who were all mainly from the same area near the Sahara desert.
During a second phase police broke up another gang linked to the first group which smuggled minors from Morocco to Spain by boat, but which also kidnapped minors who were brought in by rival groups and held them for ransom in forests or safe houses in the southern province of Cadiz.
"The criminal gang collected money by extorting the minors' families in Morocco, sometimes using violence and threats, until they paid a ransom of 500 euros to release the children," Europol, which worked with Spanish police on the operation, said in a statement.
Spanish police said they had smashed this second group with the arrest of six of its members.
The Strait of Gibraltar separates Spain and Morocco by around just 15 kilometres -- a ferry ride between the two continents takes roughly 40 minutes -- making it one of the key smuggling routes for illegal immigrants crossing into Europe.
Spain is the third busiest gateway for migrants arriving in Europe, still far behind Italy but catching up fast with Greece.
According to the International Organization for Migration, more than 22,400 people arrived in Spain by sea last year, nearly triple the number for 2016. Some 223 people died along the way.