Forty people mostly of Nigerian origin have been charged with running a sex trafficking ring in Spain in which they forced women to work as prostitutes from caves.

The network spanned Andalucia, the Basque Country and Castilla la Mancha and the victims included minors. Thirteen victims rescued from caves in the province of Almeria, the Olive Press reported.

The first phase of the operation earlier in November, netted 27 suspects, 24 of whom were placed in provisional prison without bail.

According to El Mundo, the other three suspects, who were released, had their passports taken away and will be required to appear every week before their trial.

The group was charged with being part of a criminal organisation, human trafficking, induction to prostitution and money laundering, Judge Juana López said in an Alicante court.

The second phase of the operation took place in Alicante, Torrevieja and in the Almerian municipalities of Vera and Roquetas de Mar.

The suspects are accused of sexually exploiting their victims by forcing them to prostitute themselves in roundabouts and flats in several Spanish cities, according to El Mundo.