“We’ve watched him closely,” said Seth DuCharme, a prosecutor who worked with him when he ran the counterterrorism unit of the United States attorney’s office in Brooklyn. “And we have developed — with a great sense of caution — trust in him over time.”

Mr. DuCharme made those remarks on Wednesday in Federal District Court in Brooklyn at an unusual hearing before Judge Weinstein that, in the iconoclastic jurist’s typical fashion, was part judicial process, part legal seminar. Judge Weinstein had scholars of Islamic extremism testify about factors that might push the cooperator to return to the jihadist life — and those that might keep him from doing so.

What emerged at the three-hour hearing was a story in keeping with others told by former ISIS members. It began with a dislocating trauma. In mid-2014, when the young man was studying at Columbia, one of his sisters — seven months pregnant at the time — came down with an illness that ultimately killed her and her unborn child. Another sister, who testified anonymously on Wednesday, said that he became withdrawn and suddenly renewed his interest in his family’s Muslim faith.

According to court papers, the young man came to the United States from Bangladesh when he was 1 and, as he grew, played sports, attended religious classes and confronted the “common distractions a teenager faces.” His life, the papers said, “was not dissimilar to that of many young people in New York.”

But his sister’s death darkened him, the papers said, and set him on “a path toward a confused understanding of Islamic extremism.” Prosecutors said he was especially enthralled with the ISIS rhetoric he found online.

Unknown to him at the time, agents from New York City’s Joint Terrorism Task Force were monitoring his internet activity and in the summer of 2014, court papers said, they went to see him at his family’s home in Brooklyn. The agents warned him “not to pursue a relationship with ISIS.” But the young man was alarmed by the visit and fearful of arrest, the papers said, and soon left the country. He flew to Turkey then to Syria, he said, where ISIS members picked him up and drove him to a small town north of Raqqa. This was at a moment when the group was declaring itself a caliphate and actively recruiting volunteers.