Morocco has long considered itself a haven of stability in a volatile region and a key ally in the fight against Islamic extremism, but in recent months, it has found itself shaken by carnage in Europe blamed on Moroccans who moved abroad.

Young men from the North African nation have been involved in deadly attacks in Paris and Brussels, and — just last week — emerged as suspects in violence in Spain and Finland. The Islamic State group has claimed responsibility.

In the days after attacks on Barcelona's famed Las Ramblas and a seaside resort killed 15 people, shocked and horrified relatives and friends of the suspects gathered with the Muslim community in their Spanish town of Ripoll to denounce terrorism.

Their families in Morocco issued similar statements and also said that anything the young men learned about extremism had taken place away from home.

The 12-member cell accused of carrying out the attacks in Spain was made up of brothers and childhood friends from Ripoll — young men described as integrated, well-liked and responsible members of their tight-knit community.

"Pilot, teacher, doctor .... How could this have disappeared? What happened to you?" their school counselor, Raquel Rull, wrote in a despairing column published Tuesday in La Vanguardia newspaper. "What are we doing to make these things happen! You were so young, so full of life you had a lifetime ahead ... and a thousand dreams to fulfill."

Spanish police Monday shot and killed Younes Abouyaaqoub, a 22-year-old Moroccan who was thought to be the driver in the van attack on Las Ramblas that was responsible for 13 of the deaths. He also was identified as a suspect in the slaying of the owner of a hijacked car.

His grandfather, Aqbouch Abouyaaqoub, told the Spanish newspaper El Pais that Younes left Morocco as a young boy.

"But one thing is certain: My grandson did not finish his studies here. He studied in Spain," he said.

Prominent Moroccan Islam expert Bilal Talidi cited multiple causes for radicalization among Moroccans after moving to Europe: "the tug-of-war between two identities and two educational cultures, social marginalization, a precarious economic situation and a criminal record."

Since the rise of the Islamic State group, experts say its recruitment has been less focused on religious motivation. Instead, the group has successfully sought out relatively secular young men with a foot in both cultures. An estimated 1,600 Moroccans have joined in recent years.

Politicians and experts decry the government's failure to grasp the scope of young Moroccans' problems at home and in immigrant communities abroad, and are searching for ways to infuse their countrymen everywhere with this message of religious moderation.

Moroccans have not been the only ones staging attacks in Europe; violence has been carried out by emigres from Tunisia, Algeria, Pakistan and Libya, as well as those from European backgrounds. Moroccans also have been victims: Dozens have died in attacks in Casablanca and Marrakech.

Spain has been the main destination for Moroccans for decades. The two countries nearly touch across the Strait of Gibraltar, and Spain has two enclaves in North Africa separated from Morocco by a multiple barbed wire fences intended to prevent illegal crossings.

Moroccan security officials have made fighting extremism a priority, and the government says that since 2002, they have dismantled 167 terrorist cells and thwarted 341 attacks.

King Mohammed VI routinely criticizes jihadism and the discourse of radical Islam.

"In the face of the proliferation of closed-minded ideas in the name of religion, everyone — Muslims, Christians, Jews — should form a common front to counter fanaticism, hate and isolationism in all its forms," he said in a speech last year. He urged Moroccans abroad to "remain attached to the values of their religion and their secular traditions in the face of this phenomenon that is foreign to them."

Since the 1970s, Morocco has worked to supervise religious teaching of its communities abroad through multiple government agencies, according to Abdelkrim Benatiq, the minister for Moroccans abroad.

Asked by The Associated Press about those efforts, Benatiq referred questions to the Islamic Affairs Ministry, which did not respond to requests for comment.

The government has earmarked $24.5 million for these efforts this year alone, in addition to imam training programs by the Mohammed VI Institute.

But Talidi cautioned that "religious frameworks cannot provide much help for youth with criminal records, who don't go to places of worship or religious teaching."

He added that "Morocco places people who are not supported by the community abroad to religious posts, which creates a climate of tension and divisions, instead of working in a spirit of partnership with people who are more representative" of the local population. At the center of the cell was an itinerant imam who, his family told El Mundo newspaper, had not lived in Morocco in 15 years.

Youssef Gharbi, president of the commission for foreign affairs, Islamic affairs and Moroccans abroad in the lower house of parliament, said one of the main challenges is how to pass along Morocco's cultural heritage and identity based on tolerance to a younger generation of emigres.

"Their views of their identity and of Islam are deformed, and based on a radical interpretation of religion," Gharbi said.

He wants parliament to make this issue a priority.

"A large number of youth of the third and fourth generation of Moroccans abroad don't know our country," Gharbi added. "Their desire to reconnect with religion is sometimes made in a violent way."

He proposes cultural programs for Moroccans born abroad that encompass more than just religion, with coordinated efforts among government agencies, nongovernment actors and community groups.

Rull, the school counselor who knew all of the attackers, implied in her column that the answer must go deeper and reach across the Mediterranean. The day after Abouyaaqoub was shot to death, she had more questions than answers.

"How could this be, Younes? My fingers tremble. I have never seen anyone as responsible as you," she wrote.


Associated Press writer Lori Hinnant contributed from Barcelona.