It was a little less than a year after they met that the pair left for Syria, in the summer of 2015.

In a jarring video that appears to be addressed to her parents and was obtained by a Swedish tabloid, the Aftonbladet, a bearded young man who seems to be her boyfriend and identifies himself as Mokhtar Mohammed Ahmed speaks into the camera in Swedish, saying, “You can just forget about this little girl, because she is never coming back.”

The circumstances of how she eventually did come back remain unclear. Senior Kurdish officials say she was rescued on Feb. 17 by Kurdish special forces without a shot being fired. The officials said they were able to locate her using information derived from her occasional use of the Internet, but they offered no details.

A sheikh interviewed in the Kurdish city of Erbil said he had been approached by the girl’s uncle, who he said worked for Unicef, to try to get her out. The sheikh said he had received photos of landmarks from Tel Keif, a village near Mosul, that Ms. Nevalainen was able to send to identify her whereabouts. He claimed he had been able to arrange her escape with smugglers and was supposed to be paid $35,000. He said that the next thing he knew, he saw the girl on television — and that he had never been paid.

The release of foreigners by the Islamic State is rare; most cases have involved ransoms. Kurdish officials denied that any ransom was paid, and the Swedish government and the girl’s parents have declined to provide any details.

Ms. Nevalainen’s case highlights how even villages in the heart of rural Sweden are grappling with the presence of increasing numbers of Muslim refugees, some of whom may bring with them preconceptions about the West and even allegiances to groups in fiery Middle East conflicts.

In his video, the young man believed to be Ms. Nevalainen’s boyfriend says the reason he and Marilyn left Sweden was racism.