Months later, in phone calls, emails and text messages, the terrorist group negotiated with the Red Cross, initially demanding a ransom of less than 1 million euros — under $1.1 million — and calling for the release of detained ISIS fighters. But the ransom fluctuated as time went on, the aid group said, rising to €20 million before dropping down to €5 million, the amount requested for several other Western hostages.

In those exchanges, the Red Cross was able to send proof-of-life questions, asking for the number of Ms. Akavi’s insurance policy, which her family said was written on a card the nurse kept with her. ISIS provided the correct number, one of several personal questions the group answered that convinced the Red Cross it was in fact speaking to her captors, Mr. Daccord said.

By early 2014, the aid group confirmed that Ms. Akavi was being detained in a facility next to an oil installation outside Raqqa. She shared a cell with an American aid worker, Kayla Mueller, according to the aid group and others who were in the same jail. An adjacent cell held more than a dozen male prisoners from Europe and North America, including the American journalist James Foley, as well as Mr. Cantlie, the only other Western hostage who may still be alive, according to a statement in February by a British government official.

By mid-2014, ISIS had released most of the hostages after their governments, and sometimes their employers or families, paid multimillion-dollar ransoms. But three British and four American citizens, whose governments hew to a strict no-ransom policy, remained behind, along with Ms. Akavi.

That August, after failing to get a ransom for his release, ISIS killed Mr. Foley. His beheading, and the similarly brutal deaths of two British hostages and the remaining American men in the next few months, shocked the public and rattled the Obama administration. That set in motion a military intervention in Syria that ended just weeks ago with the collapse of ISIS’ rule.

The female prisoners were initially spared, even though ISIS sent the Red Cross an email in July 2014 saying it planned to execute both Ms. Akavi and Ms. Mueller as retaliation for a failed rescue attempt by American commandos, according to Mr. Daccord.

By autumn, the women were sharing their cell with two Yazidi teenagers who had been abducted with thousands of other women in Iraq to be used as sex slaves.