Watch A Perfect Terrorist , FRONTLINE and ProPublica’s investigation into the mysterious circumstances behind American David Coleman Headley’s rise from heroin dealer and U.S. government informant to plotter of the 2008 attack on Mumbai. Also check out our interactive exploring Headley’s web of betrayal

Update (1/17): This story has been updated and expanded to reflect results of Tahawwur Rana’s sentencing hearing.

CHICAGO — A federal judge Thursday sentenced a Chicago immigration consultant to 14 years in prison for his role in supporting the Pakistani terrorist group that worked with Pakistan’s intelligence service to carry out the 2008 Mumbai attacks and plot a follow-up strike in Denmark.

Prosecutors had requested a 30-year sentence for Tahawwur Rana, 52, whom a jury convicted in 2011 on two counts of material support of terrorism of the Lashkar-i-Taiba militant group and of a plot to attack a Danish newspaper that published cartoons of the Prophet Muhammad.

Rana had been acquitted on charges of serving as an accomplice in the Mumbai attacks, which killed 166 people, including six Americans. His 2011 trial, however, revealed strong evidence that Pakistan’s spy agency, the Inter-Services Intelligence Directorate (ISI), played a direct role in an operation that was designed to kill Americans and other Westerners. Pakistan receives billions of dollars in U.S. aid.

Rana’s relatively minor role in the case grew out of his long friendship with the star prosecution witness: the enigmatic David Coleman Headley, who used a cover as a representative of Rana’s immigration firm to do reconnaissance in India and Denmark. Headley, a Pakistani-American businessman and former drug informant, avoided the death penalty by pleading guilty to participating in those plots as an operative of Lashkar, the ISI and al Qaeda. He is scheduled to be sentenced next week.

At Thursday’s sentencing, U.S. District Judge Harry Leinenweber cited a key finding by the jury in Rana’s trial. Despite Rana’s awareness that Headley was involved with Lashkar and the ISI as early as 2005, the judge said the jury had accepted Rana’s argument that he was not aware of the Mumbai plot and that his support of Lashkar did not play a role in that 2008 massacre.

The judge rejected a prosecution request for a “terrorism enhancement” of the sentence on the grounds that the foiled 2009 plot was intended to influence the Danish government. Instead, Leinenweber found that the target was limited to the Jyllands-Posten, a private newspaper, and was meant to intimidate journalists.

On the other hand, Judge Leinenweber chose a punishment that was higher than the minimum 11 years in prison. He underscored the seriousness of the crime, recalling that the terrorist masterminds wanted a team of gunmen to storm the newspaper building in downtown Copenhagen, decapitate hostages and throw the heads out of the windows to provoke public horror and a frantic police response. The judge also said Rana’s awareness of Headley’s involvement in the Mumbai massacre left no doubt as to the murderous potential.

A mindset that would contemplate such a slaughter “is something that I just frankly don’t understand,” Leinenweber said. “This is about as serious as you can get. It only would have been more serious if it was carried out … Something I have to take into consideration is to protect the public from future crimes of this defendant.”

Leinenweber also added five years of post-prison supervision to Rana’s sentence.

The bespectacled Rana, who wore an orange prison uniform, did not make a statement in court. He has aged considerably since his arrest in October 2009. His hair and beard have turned gray, and he suffered a heart attack and other health problems in Chicago’s Metropolitan Correctional Center. As an accused terrorist, he was held for 13 months in a harsh solitary confinement regime usually designated for problem inmates, according to his lawyer, Patrick Blegen.

Arguing for leniency, Blegen described Rana as a loving father of three with no criminal record and a background as a medical doctor in Pakistan and a businessman in Canada and the United States. Although he said Rana accepts blame for his crime, he called his client another victim of Headley, whose globe-trotting odyssey as a drug dealer, U.S. Drug Enforcement Administration informant, terrorist and Pakistani spy was full of deception and manipulation.

Rana and Headley’s friendship began when they attended military school in Pakistan. Rana later helped Headley overcome his heroin addiction, Blegen said, and put up his house as bond when Headley was arrested on heroin smuggling charges. Rana’s attorneys have criticized the plea bargain that allowed Headley, a frontline operative who had access to Pakistani terror chiefs and spymasters, to testify against his old friend.

“It’s impossible to talk about Rana without talking about Headley,” Blegen said. “He got sucked into this by Headley. There was no suggestion he was looking to do jihadist things on his own. He was someone who succumbed to the advances of Headley.”

In contrast, Assistant U.S. Attorney Daniel J. Collins cited intercepts of conversations in which Rana praised the mastermind of the Mumbai plot and said the gunmen who carried out the massacre deserved Pakistan’s highest military honor. Rana’s willingness to join the Denmark plot reveals his true personality, Collins told the judge.

“He knew they had blood on their hands,” Collins said. “And it didn’t give him pause for an instant. That speaks volumes about who he is.”

There was little discussion during the sentencing hearing about the most explosive aspect of the case: the revelation of the ISI’s active role in terrorism against the West. One difficulty that prosecutors faced was that Rana had contact with Headley’s ISI handler and an al Qaeda operative, but not with Lashkar figures other than Headley. The sentence and jury verdict reinforce the defense’s assertion that, during the three years he prepared the Mumbai attacks, Headley kept Rana largely in the dark and duped him into thinking they were working mainly with the ISI on espionage in India.

Rana helped Headley conduct undercover terrorist reconnaissance by allowing him to work as an overseas representative of his immigration consulting firm. Rana enabled Headley to open an office in Mumbai, use business cards, obtain visas and otherwise maintain a cover.

The two friends were arrested in Chicago in October 2009 as Headley prepared for a third visit to Denmark to conduct surveillance for an attack on the Jyllands-Posten. In trial testimony that gave an unprecedented look into the terrorist underworld in Pakistan, Headley described how he was recruited, trained, funded and directed by Lashkar and the ISI to do two years of surveillance on luxury hotels, a Jewish center and other targets in Mumbai.

Federal prosecutors used Headley’s account and corroborating evidence to file charges against a suspected mastermind of the Mumbai attacks known only as Major Iqbal, Headley’s alleged ISI handler — the first time the U.S. government has charged a serving Pakistani intelligence officer with terrorism. Major Iqbal is charged with the murders of six U.S. citizens who died in Mumbai. Pakistan has refused repeated U.S. requests to arrest him.

Prosecutors also charged three Lashkar bosses who directed the three-day rampage by 10 gunmen in Mumbai from a control room in Pakistan. Pakistani authorities arrested one of those militant bosses and a few other suspects, but their trial in Pakistan has stalled. The failure to judge them and capture other top figures has intensified accusations that Pakistan protects Lashkar, which Western and Indian counterterror agencies regard as a proxy of the ISI.

Major Iqbal remains a serving officer in the ISI, and accused masterminds, including Sajid Mir, whose voice was caught on telephone intercepts as he directed the slaughter in Mumbai, continue to run the terrorist group, according to Western and Indian counterterror officials.