There was a man from Long Island who, after dropping out of the United States Army during training, traveled to Afghanistan to fight American troops alongside the Taliban.
And there were two high-school classmates from Flushing, Queens, who trained at a terrorist camp in Pakistan and returned to the United States with orders to stage suicide attacks on New York City subways during rush hour.
This was the cast of characters that took the stand as cooperating witnesses for the government in the trial of Adis Medunjanin, a Queens man who is accused of participating in the subway bombing plot, which federal officials have called one of the most serious threats to American security since the Sept. 11 attacks.
The jury hearing the case in Federal District Court in Brooklyn is expected to begin its deliberations on Monday. Mr. Medunjanin faces up to life in prison if convicted.
A rare terrorism trial stemming from a credible plot that was days away from being executed has yielded the even rarer spectacle of admitted terrorists testifying for the government they had sworn to fight — and against one of their own.
The testimony of the four men — Zarein Ahmedzay, Saajid Badat, Bryant Neal Vinas and Najibullah Zazi — was interspersed with moments of tears, conviction and regret, and provided a detailed and unusually human window into a normally secretive world, as each man described the journey that led him to the cusp of committing mass murder on behalf of Al Qaeda.
Though there are limits to what can be extrapolated from their personal tales, common themes emerged. They were all young Muslim men living in the West who were influenced by the fiery preaching of radical clerics: most often by Anwar al-Awlaki, who called on all Muslims to take up arms.
All of them traveled to the Middle East to fight against American troops in protest of what they viewed as the occupation of Afghanistan. They were all recruited to terrorist training camps, where they were told by Qaeda leaders that their passports made them far more valuable as suicide bombers back home, and they all struggled with the moral implications of their actions as they prepared to kill as many people as possible.
All four men pleaded guilty: three are testifying in the hope of leniency at sentencing, while the fourth, Mr. Badat, was released early from a prison in Britain in exchange for his cooperation.
Mr. Zazi said he hoped to get “a second chance.”
The government has highlighted the cooperation of four convicted terrorists as a sign of its success in undermining groups like Al Qaeda by using the threat of punishment to get their members to turn on one another, in much the same way as prosecutors took on the mob in an earlier era.
“As you apply a law enforcement model to these cases, people always cooperate,” said Anthony S. Barkow, a former federal prosecutor who specialized in terrorism cases and now works in private practice. “It took a long time in organized crime; it is taking less time with national security.”
On the stand, the men professed their Islamic faith but distanced themselves from the Qaeda leadership, which one man said had “brainwashed” him and another accused of using young religious fighters as pawns.
Their appearances in a usually sleepy courthouse in the heart of Brooklyn — which went unnoticed by the families who played each day in the park outside — have been used by some as evidence that the United States justice system was well positioned to handle terrorism cases.
“The federal courts are not just about providing due process and protecting defendants’ rights,” said Jonathan Hafetz, a professor at Seton Hall University School of Law who focuses on national security. “There is an information-producing function that allows the public to see how terrorists act and how the government acts to prosecute these terrorists.”
He added, “That’s something that we lose when we deal with more secretive processes like military commissions.”
The testimonies of Mr. Badat and Mr. Vinas were unrelated to the 2009 subway bombing plot that was the subject of Mr. Medunjanin’s trial. Instead, they were called as expert witnesses about Al Qaeda to corroborate facts about terrorist training camps in Afghanistan and Pakistan.
The camps Mr. Badat described encountering in 1999 — situated in major cities, with feasts, singalongs and even sporting events — seemed to bear little resemblance to the secret, mud-walled facilities encountered by Mr. Ahmedzay and Mr. Zazi a decade later.
Mr. Badat, the British man who was prepared to board a plane with a bomb sewn into his shoe before backing out of the plot in 2001, testified by video to his role in the conspiracy.
He described his radicalization as a “gradual process,” which accelerated when he became friendly with people who had taken up arms to fight for Islamic causes.
“It was almost the glamour factor of it drawing me in,” Mr. Badat testified. “So it was my desire then to go and at least acquire some training in taking up arms.”
For several of the witnesses, friendship played a large role in their radicalization. Mr. Ahmedzay and Mr. Zazi, who pleaded guilty in the subway plot, described listening to radical lectures together on a single iPod, with one man using the left earpiece and the other the right.
Mr. Zazi cried when talking about his love for the former high-school classmate against whom he was testifying.
Mr. Badat agreed to cooperate with the British and American governments on the condition that he never have to testify against a good friend from London who had introduced him to violent jihad.
When it came time to carry out their attacks, each of the witnesses withdrew or failed.
Mr. Badat decided not to board the plane and dismantled the bomb in his shoe, keeping the components under his bed for two years until his arrest.
Mr. Vinas, who decided he would rather carry out a suicide mission than deal with altitude sickness in the mountains of Afghanistan, was ultimately ruled out because Qaeda leaders did not think he had enough religious knowledge.
The plot of Mr. Ahmedzay and Mr. Zazi was derailed by law enforcement, but it had already been downsized because Mr. Zazi had lost a page of his bomb-making notes.
Other details emerged that provided insight into the thinking of the Qaeda leaders to whom the men answered. Mr. Ahmedzay recalled being cautioned against planning overly ambitious attacks on the scale of Sept. 11 because such attacks so often failed.
“If you can’t make a big bomb, do something smaller,” he recalled the leaders saying. “Other missions have failed because they tried to do a big thing.” Just going into a crowded area and shooting people, Mr. Ahmedzay said he was told, was better than nothing.