The lakes and forests of Scandinavia might seem an unlikely place to find the child bride of an Islamist warrior. But flawed integration of a fast-growing immigrant minority has combined with the internet to turn Sweden into a new recruiting ground for the proclaimed caliphate.

When Marilyn Nevalainen, a white, Swedish, 14-year-old, fell for a north African refugee, she started a journey that ended in Mosul in Kurdish Iraq, where she was rescued from Islamic State militants last week.

Born in a Swedish family in rural Mark county, south-west Sweden, Marilyn, now 16, moved in with foster parents in Halland, south of Gothenburg. Her 19-year-old boyfriend started talking to her about Isis, and showing her films. When he asked her to go with him to Syria, she said yes.

“She was young girl from a semi-dysfunctional family who, against her better judgment, fell in with the wrong guy,” said Magnus Ranstorp, of the Swedish Defence University, Stockholm, where he leads research on violent extremism. “There are lots of young people who are naive and oblivious to these groups, some girls go with a romanticised notion of a utopia. This one picked the wrong boyfriend and ended up in a terrible situation.”

Marilyn was just 15, and perhaps already pregnant, when she left Sweden in May 2015. Once reaching Syria, she and her boyfriend were taken to Mosul in Iraq, according to Kurdo Baksi, a Kurdish-Swedish journalist who specialises in Middle East affairs.

The boyfriend went to fight in Ramadi, and it is not known whether he is still alive. The fate of her child was also unknown, Baksi said.

Marilyn is not the first Swedish-born teen to be lured by Islamist extremist groups. About 300 Swedes have joined jihadi groups in the Middle East, making Sweden second only to Belgium as the largest contributor of Islamist militants from Europe. A third of the recruits are under 18, while between 30 and 40 are minors, according to official figures. It is thought 20 have died in action. Two are facing trial for alleged terror offences, while another two have been charged in absentia. As many as 130 have returned to Sweden.

Sweden is fast waking up to the fact that it has a problem. In 2014 Stockholm appointed a “national coordinator for protecting democracy against violent extremism”, and three months ago established a hotline enabling concerned citizens to make anonymous tipoffs or find advice.

“We have had far-right, white extremism for a long time in Sweden, but religious extremism is something new,” said Haisam A-Rahman, one of two coordinators of Gothenburg’s efforts to combat violent extremism.

An underlying problem, A-Rahman said, was that Gothenburg had levels of segregation similar to Harlem, in New York, during the 1970s. “It is one of the most segregated cities in Europe. Gothenburg is divided, polarised between those who are inside the system and those who feel they are outside, that they don’t belong.”

Vulnerable young people could change at terrifying speed, giving society just a brief window to act, A-Rahman said. He gave the example of another apparently normal 15-year-old girl who was very social, active in sports, and with large group of friends. One day last year she asked the school nurse for a series of vaccinations, and the nurse contacted the anti-extremism coordinators. At the same time a relative got in touch, saying there had been a sudden change – the teenager had quit the soccer team, was not seeing her close friends, was not eating like the rest of the family, and was sleeping on the floor instead of her bed, as if she were preparing for something.

Her behaviour altered over the course of just four to six weeks, A-Rahman said. They found she had bought a ticket to Turkey, from where she planned to cross into Raqqa, hoping to meet and marry the man who had been grooming her online for some time.

Only two Swedes had tried to get to Syria since the summer, A-Rahman said, and not a single person from Gothenburg. It suggested a significant decline. “This phenomenon changes on a monthly basis,” he said. “Social media have such an important role in recruitment. Sometimes it feels like riding the train while laying the rails.”

Some of the girls joining Isis were impressionable and following their boyfriends, while others were groomed online and wanted to rebel against patriarchal restrictions in their families, Ranstorp said. Others, he said, should not be viewed as passive victims but were very involved and could be acting as recruitment sergeants.

Research has shown that underpinning this is the fact that many of the youngsters come from vulnerable backgrounds, with low or no income, relationship problems, and involvement in petty crime. “What better way to turn a new leaf and go from being the biggest loser to the biggest hero? They just leave everything behind,” Ranstorp said.

Christer Mattsson, who leads Gothenburg’s new Segerstedt Institute, covering violent extremism, had been working for many years in the city with young white people classed as racists, before he began seeing signs of Islamist radicalisation 10 years ago.

One of the first Swedes to be convicted of Islamist terrorism came from the suburb of Kungälv, where Mattsson was developing his Tolerance Project. Mirsad Bektašević, a Serbian refugee to Sweden, was arrested in Sarajevo in 2005 and spent several years in jail in Bosnia and Sweden on terror charges. “Bektašević and his friends were the first, and that was when we understood we had to develop tools to deal with them,” Mattsson said.

The Tolerance Project is now being trialled elsewhere in Sweden. Young people identified as vulnerable to extremism are encouraged to join and then coached once a fortnight for several months, ending with a week in Poland investigating the highly multicultural society that existed before the Nazis wiped it out.

Jakob, 17, joined the Tolerance Project at his school when he was 15 because it seemed like a chance to skip lessons. Born in Sweden, of Kurdish Muslim parents, his friends and siblings were close to the group of radicals around Bektašević. He was involved in petty crime and hated Roma immigrants.

“I just wanted to go to Poland for a week’s holiday,” Jakob said about the project. “But after a while I began to was think that this stuff was really important.”

Playing football in an impoverished Roma village in Poland was the final point in changing his perspective on life, he said. “Thanks to this project I found myself,. I was doing bad stuff, but I became a better person. Now I don’t look down on other people. I found myself.”