The terror network allegedly headed up by ex-Guantanamo Bay prisoner Lahcen Ikassrien used the mosque, Madrid's largest, as its centre of operations, National Court judge Pablo Ruz said in a ruling as he processed 15 members of the gang dismantled in June.
In a 49-page report, Ruz outlined the activities of the group, which is thought to have been in operation since 2011 and to have operated a training camp near the Spanish city of Ávila.
The group, known by its members as the Al-Andalus Brigade — a reference to the Islamic-controlled area of Spain of the Middle Ages — left a trail of evidence including paperwork, videos and social media content outlining how they operated.
One such example is that of Hicham Chentouf, who joined Isis in autumn of 2013. This young man started attending the M-30 mosque in 2010 and became radicalized after contact with the cell led by Ikassrien. He went on to become an imam at the Yunquera de Henares mosque in Spain's Guadalajara mosque.
In 2014, Chentouf posted on his Facebook page a message from the head of operations for Isis in Homs giving him permission to take a week's leave from combat. He had earlier posted a photo of himself brandishing an AK-47 rifle, Spain's El País newspaper reported.
Ikassrien, described by the judge as the cell's charismatic leader, is now facing 12 years in prison for heading up a terror cell, and has also been accused of falsifying documents after allegedly forging his Spanish residence permit.
However, the main operative for the group was Omar El Harchi who organized financing and recruiting for the group, the judge said. El Harchi purchased plane tickets for two members of the group who died in combat in Syria in 2012.
Ruz will now hear statements from the members of the ring before they they go on trial.
Thursday's hearing came on the same day that ten Mediterranean nations — including France, Italy, Algeria and Libya — on Thursday pledged greater cooperation in the fight against Islamic radicalism and illegal immigration during talks in Spain.
The vow came at the close of a meeting of defence ministers in the southern city of Granada from the so-called 5+5 initiative set up in 2004 to boost cooperation in security matters among 10 nations from around the Mediterranean.
In a joint statement they promised to "work with a renewed strength" to "tackle the security changes that we face, in particular illegal immigration, organized crime and terrorism".
The 5+5 initiative also includes Tunisia, Mauritania, Morocco, Portugal and Malta.
Story continues below…
Spanish Defence Minister Pedro Morenes, who hosted the gathering, expressed his "firm support" for the "legitimate government of Libya.
"We face common threats: Islamist terrorism, drug smuggling, human trafficking, massive illegal migration, all are factors that affect the Mediterranean coast," he said.
"International jihadist terrorism directly affects our nations but it is also affecting countries that are not part of the 5+5 and which have the capacity to influence in our nations."
Several Islamist extremist groups are threatening the area, including jihadists from Al-Qaeda in the Islamic Maghreb who are active in Algeria and remain a major problem for Morocco.