Spain's state prosecutor charged the leader of Nigerian Islamist militant group Boko Haram, Abubakar Shekau, with terrorism and crimes against humanity over a 2013 attack on a Nigerian town in which a Spanish nun was assaulted, court papers said.

Spain has pioneered the use of universal jurisdiction, the concept that crimes against humanity can be prosecuted across borders, in instances such as when a Spanish judge issued an arrest warrant for Chile's Augusto Pinochet in London in 1998.

The Boko Haram case arises from a militant attack on the eastern Nigerian town of Ganye on March 22, 2013 in which at least 25 people were killed.

Court papers issued on Thursday said militants assaulted the nun, Maria Jesus Mayor, in Ganye before she was able to escape into hiding and was later rescued by Nigerian security services.

The court documents gave no details of the alleged incident involving the nun. The judge has asked for a study of Boko Haram from Interpol and will obtain a declaration from Mayor about the incident, according to the court papers.

For Spain to carry out universal jurisdiction, there must be a Spanish connection such as a Spanish victim or perpetrator. In the Boko Haram case, the state prosecutor used the fact there was a Spanish victim to bring a generic charge of crimes against humanity and terrorism, a court source said.

"This criminal act was committed against a background of terrorist activities that the jihadist organization (Boko Haram) is carrying out systematically against people and communities," the court document said as it listed deadly attacks carried out by Boko Haram in Africa's most populous state since 2009.

Spain's center-right government in recent years has sought to limit the power of judges since arrest orders were causing diplomatic friction, for example last year when a judge went after former Chinese officials accused of genocide in Tibet.

As a result, the universal jurisdiction law was changed last year so that judges could investigate such cases only if there was a Spanish connection.