Held for nearly two years in a prison run by an affiliate of Al Qaeda in Syria, an American freelance writer was unexpectedly freed on Sunday, following extensive mediation by Qatar, the tiny Gulf emirate and United States ally that has successfully negotiated the release of numerous Western hostages in exchange for multimillion-dollar ransoms.

Relatives of the freed hostage, Peter Theo Curtis, 45, said that while they were not privy to the exact terms, they were told that no ransom had been paid. Yet his surprise liberation by the Qaeda affiliate, the Nusra Front, came less than a week after the decapitation of another American journalist, James Foley, held by a different and even more radical jihadist group, the Islamic State in Iraq and Syria.

Mr. Curtis’s release was likely to raise further questions about what, if any, concessions should be made to militant groups holding Western nationals. The beheading of Mr. Foley, which shocked and enraged much of the world, also may have spurred Qatar to press more intensively for Mr. Curtis’s release.

Mr. Foley’s death, apparently at the hands of a masked ISIS guard believed to be British, which was filmed and uploaded on YouTube, came after European nations and organizations had negotiated the liberation of more than a dozen of their citizens held in the same cell as Mr. Foley for ransoms averaging more than $2.5 million, according to former hostages, their families, negotiators and officials involved in their releases.

News of Mr. Curtis’s release came as British officials said they were close to identifying Mr. Foley’s suspected killer, based on voice-recognition technology, eavesdropped phone recordings and other intelligence tools. If the suspect is identified, it could give officials insight into the ISIS captors, who are holding another American journalist, Steven J. Sotloff, and two other Americans.

Relatives of Mr. Curtis said in an interview that after numerous failed starts and after having received ransom demands ranging from $3 million to $25 million, the panicked family was introduced by Samantha Power, the United States ambassador to the United Nations, to her Qatari counterpart after learning that Qatar had successfully won the release of Europeans kidnapped by Al Qaeda’s branch in Yemen. As soon as Qatar became involved, the relatives said, they felt as if an avenue of communication had been opened. For the first time, they were able to send a proof-of-life question which only Mr. Curtis could have answered: What was the subject of your Ph.D. dissertation? (Answer: a museum started by the mother of the novelist Anthony Trollope.)