Somali pirates kidnapped and held Michael Scott Moore, a journalist, hostage for 2½ terrifying years until a ransom payment secured his release in September 2014.

Two months later, Moore received a surprising message on Facebook.

"How are you, Michael?" the message said. "I am ur friend Mohammed Tahlil. I wants to speak with u."

The sender's Facebook page included his photograph. Moore recognized him as one of the men who guarded him during his captivity in Somalia. He decided to write back.

What followed was an extraordinary exchange of Facebook messages between the journalist and his former captor. How long they communicated and where the conversation ultimately led has not been made public, but in the summer, the Somali was taken into custody by U.S. authorities and jailed in New York City, court records show.

A federal indictment made public last week charged the man, Mohamed Tahlil Mohamed, 38, with kidnapping, hostage taking, conspiracy and other counts. Authorities have not said where he was arrested.

The indictment identified his hostage only as "John Doe," but Moore confirmed he was the unnamed victim.

When asked about the arrest of Tahlil, Moore replied, "I'm not as happy as you might imagine that he's in jail." He declined to comment further and would not say whether the Facebook exchanges had in some way led to Tahlil's capture or surrender.

Heavily armed men abducted Moore when he was doing research on piracy in January 2012 near the inland town of Galkayo. Moore's book "The Desert and The Sea: 977 Days Captive on the Somali Pirate Coast," published in July, recounted his ordeal.

It appears from the Facebook exchanges — some of which are detailed in a criminal complaint and others in Moore's book — that the journalist developed a kind of affinity for Tahlil, who, in turn, provided Moore with information about his kidnappers.

In his book, Moore, 49, described his captivity as full of terror, pain and close calls.

Moore wrote that Tahlil was "the boss" of the Somali guards who watched him and other hostages. Moore described Tahlil as gentle with "a shy, snaggletoothed smile."

It was in November 2014, after Moore had been released and had resumed using his Facebook account, that he heard from Tahlil. "I recoiled from the message and ignored him at first," he said in his book. "But Tahlil had been gentle, even good-humored, so eventually I wrote back."

Tahlil wrote that he was in Hobyo, a Somali coastal town known as a pirate den.

"I hope u are fine," Tahlil said. "The pirates who held u hostage killed each other over group vendetta and money issues."

In another exchange, Tahlil recalled how he had obtained medication for Moore and given him a radio, books, pens and other items. The complaint showed Moore responded with gratitude.

"You also brought me a little bottle of medicine from Hobyo to the ship," Moore wrote back. "All you wanted was a box of biscuits in return. I remember."

Tahlil has been detained without bond pending further proceedings. He could face life in prison if convicted.