Two Nigerian women have been arrested in Spain accused of stealing a child and forcing his mother into prostitution to pay their ransom.
Spain has cracked a number of groups smuggling Nigerian women
The mother, also Nigerian, claims her son was snatched from her shortly after he was born four years ago.
She said the women demanded 45,000 euros (£31,000) for his return and threatened her with "voodoo".
The boy was kept hidden from neighbours in a Madrid flat until police tracked him down and rescued him this week.
The kidnap and blackmail came to light when the mother, who has since given up prostitution, went to the police. She said the women had got her into Spain from Nigeria illegally - which was why she owed them money.
After they took her son, she said she worked as a prostitute in different clubs around Spain to pay off the debt.
Officers investigating the case confirmed that the woman had had a baby in 2002 and finally tracked down the suspects - identified only as Becky F, aged 27, and Faith N, aged 24.
The women were known to live in a flat with an 18-month-old girl and another young Nigerian woman. Officers could not confirm the presence of a young boy until a neighbour reported hearing cries from the flat that differed from the little girl's.
On Tuesday, the surveillance teams got the breakthrough they needed when a boy appeared on the balcony.
Police raided the flat and found the boy, his mother's passport and other items used in voodoo rituals which the suspects used "to terrorise the mother".
Police said the boy was healthy, although he showed signs of delayed development and had barely learned to talk. He has not been to school and has not been registered at any official institutions, such as health centres.
"Despite being the only black child in the block of flats, hardly any of his neighbours had seen him there or in the local children's playgrounds," the police said.
They said his captors had probably kept him hidden, alone, in the flat all day. He has now been taken into the care of social services.
In the past few years, Spanish police have broken up a number of illegal immigration networks involving Nigerian women being brought to Spain to work as prostitutes.
In March, six people were arrested in Valencia, accused of running such an enterprise.
Voodoo has often been found to be a way of threatening the women, but reports say kidnapping their children is less frequent.