Spanish police have detained a 14-year-old girl and a 19-year-old woman suspected of trying to join Islamist extremists fighting in Iraq and Syria.

Security forces stopped the teenagers on Saturday as they tried to enter Morocco allegedly to join Islamic State (Isis), whose fighters have seized swaths of Iraq and Syria, the government said.

"The detention of two women recruited for jihad is a remarkable and unprecedented event in Spain," the interior ministry said.

The girl cannot be identified because she is a minor. The 19-year-old woman was named as Fauzia Allal Mohamed. Both are Spanish citizens.

Video footage released by the Spanish authorities showed the pair, both wearing black niqabs, being led away from a small propeller plane, each flanked by balaclava-clad security men.

They were detained at the Beni Enzar border crossing in Melilla, one of two tiny Spanish territories on the north African coast, which share a border with Morocco.

"Both were trying to cross the border to Morocco with the aim of contacting the network which would move them immediately to a conflict zone between Syria and Iraq," the Spanish ministry said. "Their intention was to join one of the cells of the terrorist organisation of the self-proclaimed Islamic State."

Spain's government said Islamic State, which declared an Islamic caliphate in Syria and Iraq on 30 June, wanted to recruit as many foreign fighters as possible, luring them on jihadist websites and forums and then helping to arrange the logistics of their transfer to warzones.

"The two women detained in this police operation are a clear example of this," the interior ministry said. "Their radicalisation, recruitment and later dispatch as combatants were perfectly planned and organised by a network that operates across north Africa and has as its main goal getting the maximum number of unquestioning combatants."

The recruitment of a minor showed that the network had no regard for its targets' age or personal situation, the ministry said.

The Spanish government has said it fears that battle-hardened Islamist fighters may return to Spain from Syria and other conflict zones under the influence of al-Qaida-inspired groups, posing a threat of attacks. Spanish security forces have led at least three significant raids on jihadist recruitment cells this year, arresting more than 20 people.

This year Spain marked the 10th anniversary of the Madrid train bombings of 11 March 2004, which killed 191 people. Since that attack, more than 470 suspected Islamist extremists have been arrested in Spain, according to the government.