The driver was sweating as his white Kia pick-up truck sped along a rain-slicked Baghdad highway toward a neighbourhood bustling with open-air markets. With every jolt and turn, his pulse quickened. Hidden in the truck’s chassis was 1,100 pounds of military-grade explosives that Islamic State planned to use in an audacious attack on New Year’s Eve shoppers in the Iraqi capital.

A reckless driver on Iraq’s notoriously chaotic roads might clip him, accidentally setting off the bomb. A clash at one of Baghdad’s frequent checkpoints could escalate into gunfire, potentially igniting one hellish fireball. But there was another reason he was afraid. The driver, Capt Harith al-Sudani, was a spy.

For the past 16 months, he had worked as a mole, posing as a militant jihadi in Islamic State while passing critical information to a secret branch of Iraq’s national intelligence agency. His record was stunning: He had foiled 30 planned vehicle-bomb attacks and 18 suicide bombers, according to Abu Ali al-Basri, the agency’s director. Sudani also gave the agency a direct line to some of Islamic State’s senior commanders in Mosul, Iraq.

A 36-year-old former computer tech, he was now, agency officials said, perhaps Iraq’s greatest spy, one of a few in the world to have infiltrated the upper reaches of Islamic State. But now, on this last day of 2016, as he cruised along the four-lane crosstown highway toward his assigned target, the markets of Baghdad al Jdeidah, he had a nagging suspicion that his cover had been blown.

Every day he remained embedded with Islamic State was another day he risked his life. Today he had been caught in a small lie, the second in a matter of months. If the half-ton of C-4 plastic explosive riding alongside him didn’t kill him, Islamic State might. Before he left on this, his penultimate mission, he sent his father a text. “Pray for me,” he said.

Listening to the enemy

Iraq’s counterterrorism intelligence unit, the Falcon Intelligence Cell, may be the most important organisation on the front lines of the war on terrorism that almost no one has heard of. This article is based on interviews with the director of the agency, members of Sudani’s unit and its commander, his friends and family members, and a review of transcripts and video of operations, and text messages to and from Sudani.

A room at the Baghdad headquarters of Iraq’s counterterrorism intelligence unit, known as the Falcons. The rows of photos show Islamic State members who were caught and executed because of the agency’s work. Photograph: Ivor Prickett/The New York Times

Little known outside of the highest levels of Iraqi and allied intelligence agencies, the Falcons have placed a handful of spies inside the ranks of Islamic State. Its intelligence helped oust the extremists from their last urban strongholds last year and it now aids the hunt for the group’s leaders, like Abu Bakr al-Baghdadi.

Recently, an Iraqi-American sting based on Iraqi intelligence led to the arrest of five senior Islamic State members who had been hiding in Turkey and Syria. Iraqi officials say the Falcons have foiled hundreds of attacks on Baghdad, making the capital the safest it has been in 15 years.

US military officials consider the agency as good as they get among non-western spy services. “It has proved to be an extremely valuable unit,” said Col Sean J Ryan, a spokesman for the US-led military coalition in Baghdad. The Falcons, he said, have diminished the threat of Islamic State by infiltrating its cells, killing its leaders and terrorists, and destroying its weapons.

Basri, the Iraqi intelligence chief, credits the group’s undercover work. “A drone can tell you who has entered a building but it can’t tell you what is being said in the room where the men have gathered,” he said. “We can, because our people are inside those rooms.”

University dropout

Not many people in Sudani’s life credited him with the audacity or ambition to be a spy. Not his father, Abid al-Sudani, a strict disciplinarian who demanded unstinting obedience from his eldest son and put him to work after school in his small print shop. Not his professors at Baghdad University, who flunked him.

Admission to Baghdad University is a coveted opportunity. Photograph: Sergey Ponomarev/The New York Times

Intoxicated by the freedoms of student life, he blew a coveted opportunity, neglecting his studies and chasing women. His father gave him an ultimatum – buckle down or be kicked out of the family home. “It was a decisive moment for him,” said his youngest brother, Munther. “He was really disappointed that he couldn’t live how he wanted to.”

Sudani settled into an arranged marriage and returned to school, studying English and later, Russian. He took a mundane job monitoring surveillance systems for Iraq’s oil infrastructure. At the same time, near daily terrorist attacks were tearing Iraq apart. They ended up giving Sudani an opportunity, and a purpose.

As the government and the US occupation forces struggled to stem the insurgency in post-Saddam Iraq, Basri, then the intelligence director in the prime minister’s office, created a special unit with a narrow mission: targeting terrorist leadership ranks.

In 2006, he recruited 16 men from Iraq’s elite military units and police academies. He called his new unit Al Suquor, or the Falcons. “I searched for them like a man searches for a wife,” he said. “We were ready to take on any challenge.”

Another of Sudani’s brothers, Munaf, was an early recruit. While Harith was bored with his job and spent most evenings playing video games or hanging out in tea shops, Munaf came home from work brimming with enthusiasm.

Munaf urged his brother to apply, saying his computer and language skills made him an attractive recruit. Harith did, and in 2013 was offered a job monitoring web traffic and telephone calls of terrorist suspects. The change transformed him. “He was enthusiastic about his life for the first time in a long time,” said Munther. “He was happy. We all could see it.”

Going under cover

In the summer of 2014, a new insurgency burst on the scene. A jihadi group calling itself Islamic State seized large swathes of Iraq and Syria, declaring it a Muslim caliphate. The Falcons took on a new mission: penetrating the group with undercover agents.

Sudani volunteered. His commanding officer, Gen Saad al-Falih, said he was motivated by photos of children killed in Islamic State attacks. “He couldn’t let them do that,” Falih said. “He was a father himself.” Sudani was promoted to captain and began training to pass as a jihadi.

When he was young, the Sudani family had lived in Ramadi, in Iraq’s Sunni Muslim heartland. The Sunni minority had ruled Iraq under the dictatorship of Saddam Hussein. After the Americans ousted him in 2003, extremists exploited the anger of disempowered Sunnis to build the insurgency that would later become the Islamic State.

Captain Sudani’s wife Raghad Chaloob looks at photographs of her late husband at her home in Baghdad. Photograph: Ivor Prickett/The New York Times

Sudani’s ability to adopt the Ramadi accent would help his credibility with the group. But as a Shia, he was unfamiliar with Sunni rituals and prayer. So he pored over the Koran, memorising verses favoured by jihadis and learning the chants they used for praying and killing.

He would become known as Abu Suhaib, an unemployed man from a predominantly Sunni neighbourhood in Baghdad. His mission: infiltrate a notorious Islamic State lair in Tarmiyah, a town near the intersection of two highways that was a hub for suicide bombers heading to the capital.

On a September night before his mission was to start, he stayed up with his brother Munaf, drinking tea and listening to crickets chirp in the warm air as Munaf gave him a pep talk. “He was the first of us to volunteer for such a mission,” Munaf said. “It was a real risky thing he was doing.”

The next morning, Sudani walked into a mosque in Tarmiyah that the local Islamic State cell used for meetings. He stayed inside all day, longer than he and his superiors had planned. Munaf, who was part of the surveillance team monitoring his brother, was certain that something had gone terribly wrong.

Around dusk, he recognised his brother’s loping silhouette coming to the prearranged exfiltration spot. Sudani reported a success – the cell had welcomed Abu Suhaib. He was going back to live with them in Tarmiyah.

The bomb courier

His first days with Islamic State were filled with training on religion and explosives. A few weeks later, a senior Islamic State official in Mosul called. He assigned Sudani a key part in the logistics chain for suicide bomb missions in Baghdad. Believing him to be a Baghdad native, the group considered him crucial to get bombers past checkpoints on the outskirts of the capital and inside the city.

In weekly phone calls, Mosul would order Sudani to meet suicide bombers arriving in Tarmiyah from Islamic State-held territory, or to pick up a vehicle bomb. Each time, he would alert the Falcons. Their task would be to intercept him and his deadly packages before they reached Baghdad.

A chase car would follow Sudani as he drove, using jamming equipment to block the signal to the bomb’s detonator, which is usually set off remotely by mobile phone. Communicating by phone or hand signals, his comrades would direct him to a place where they could disable the bomb. If he was transporting a bomber, they would lure him out of the car to be arrested or killed.

Then the Falcons would stage fake explosions and issue fake news releases, sometimes claiming large casualties – part of the effort to keep Sudani’s cover intact.

The pressure took a toll on his health. He complained of chest pains, which he thought were anxiety attacks. “Imagine being the driver of a truck filled with 300 kilograms of explosives,” Munaf said. “You are thinking you could die at any moment. He did this over and over again.”

Stern, strict and traditional: Captain Sudani’s father, Abid al-Sudani, with his wife, Laisa Hashim Shuaith, and one of Sudani’s daughters. Photograph: Ivor Prickett/The New York Times

His long, unexplained absences from home raised fresh tensions within the family. Only his father and Munther knew about his secret life. His wife, Raghad Chaloob, thought he was neglecting her and their three children. “I regret that he didn’t tell me,” she said later, sitting in their one-bedroom apartment within the Sudani family house. “I guess he knew I would be worried if I knew the truth. No one wants her son to grow up without a father.”

Suspicion and lies

The longer Sudani worked undercover, the greater his risk of exposure. Still, he chose to continue. Falih said Sudani told him that he had finally found a purpose in life. “It was a golden time for us,” Falih said. “It was a golden time for him.”

The Falcons’ operations were crucial in turning the momentum of the US-led coalition’s battle against Islamic State. Its intelligence led to the deaths of seven top Islamic State leaders and guided dozens of coalition air strikes, according to Hisham al-Hashimi, an independent Iraqi security analyst.

By mid-2016, there was growing optimism that the group could be defeated. Sudani’s handlers in Mosul had increased his duties, asking him to scout neighbourhoods and cafes in Baghdad as targets for possible attacks. On one such mission, he tried to sneak in a rare visit home. While there, his Islamic State commander called, demanding to know where he was. Sudani said he was at the target neighbourhood.

The commander told him he was lying, citing his phone’s GPS co-ordinates. That may have been the first red flag. Munaf told his brother that it was time to end his mission. Sudani refused. By December, however, he was firmly in Islamic State’s crosshairs. The group was on its heels militarily, losing ground in Syria and struggling to hold on to Mosul. Its response was to carry out more and bigger terrorist attacks, loudly declaring its continued relevance by inspiring mayhem around the world.

On December 19th, the group sent a tractor-trailer careening through a Berlin Christmas market, killing 12 and wounding dozens. On December 31st, the Mosul commander told Sudani he had been chosen to take part in a spectacular New Year’s Eve attack, a series of co-ordinated bombings in multiple cities around the world.

Sudani picked up the white Kia in the eastern Baghdad neighbourhood of Al Khadra. As usual, he phoned the Falcons to discuss where they would intercept him.

Coming undone

The plan began to unravel as soon as he veered off the city’s main crosstown highway toward the Falcons’ safe house. His phone rang. It was Mosul, asking his location. Sudani assured the caller that he was en route to the target. The handler said he was lying. Sudani frantically struggled to invent an excuse. He told Mosul that he must have made a wrong turn.

Captain Harith al-Sudani’s wife, Raghad Hasan Chaloob, centre, and their three children, Riyam, Rawan and Muamal on the roof of their home in Baghdad. Photograph: Ivor Prickett/The New York Times

Spooked, he called his Falcons teammates, telling them they needed a rendezvous much closer to the planned attack site. He turned the truck-bomb back on the road to Baghdad al Jdeidah. Munaf, who was part of the chase team, used hand signals to direct his brother to the new meeting point.

Eight agents dismantled the bomb. They removed the electronic detonator, 26 plastic bags of C4, ammonium nitrate and ball bearings from the chassis and door panels of the vehicle. In minutes, Sudani was back on the road to the market and parking the pick-up at its intended location.

Just before midnight on New Year’s Eve, Arabic media, citing Iraqi security officials, reported a white truck had exploded outside Al Bayda Cinema in Baghdad al Jdeidah, causing no casualties. Sudani’s mission was a success. What he didn’t know was that Islamic State had planted two bugs in the truck, allowing the extremists to hear his entire conversation with the Falcons.

“He felt that he was under suspicion,” Falih said later. “We just didn’t realise how much.”

The set-up

In early January 2017, Islamic State called Sudani for another mission. It would be his last. He was sent to a new location, a farmhouse outside Tarmiyah. It was too remote to monitor and had no easy escape route. Munaf told him not to risk it, saying the change of procedure was suspicious. Sudani decided to go.

“Looking back, I can’t believe that he trusted them,” Munaf said. “I think he was blinded by a need to make us proud.”

On the morning of January 17th, he entered the farmhouse. Just after sunset, the Falcons team alerted Falih that something was wrong. Munaf called their usually stern father, who broke down. “I had never seen him cry before,” Munaf said. “He kept pleading with me to save his son, but there was nothing I could do.”

Because Tarmiyah was an Islamic State stronghold, it took three days for Iraq’s security forces to plan and mount a rescue operation. A combined army and police force raided the farmhouse. One Iraqi officer was killed. When the building was cleared, there was no sign of Sudani.

Iraqi border guard troops patrol the Syrian border near Qaim this year. Captain Sudani may have spent his final days there. Photograph: Ivor Prickett/The New York Times

For six months, the Falcons gathered evidence. They discovered the bugs in the Kia truck. Informers suggested that the jihadis had taken Sudani to Qaim, an Iraqi town controlled by Islamic State and beyond the government’s reach. In August, the Islamic State released a propaganda video showing militants executing blindfolded prisoners. The Falcons were certain that Sudani was one of them. “I grew up with him, shared a bedroom with him,” Munaf said. “I don’t need to see his face to know my brother.”

‘A wound on my heart’

In death, Sudani has achieved a level of fame unusual in the shadow world of spies. Iraq’s joint operations command issued a statement about his sacrifice for the nation. The Falcons published an ode to his bravery. On the rutted, dirt road in front of his father’s house, a pair of giant posters lauding the hero-son adorn the courtyard wall. A portrait of him is tattooed across Munther’s chest.

Posters outside the Sudani family home in Baghdad feature larger-than-life photos of Captain Sudani and poems of mourning written by his father. Photograph: Ivor Prickett/The New York Times

But the Sudani family is still struggling to get what they consider proper respect. Because they do not have a body, they have been unable to obtain a death certificate, a prerequisite to receive benefits due to fallen servicemen. “I have a wound on my heart,” said the father, Abid al-Sudani. “He lived and died for his country. The nation should cherish him the way I do.”

For the Falcons, Sudani’s successes helped it win bigger budgets, a wider appreciation among allies and better training for its men. The Americans and the Russians are now helping it penetrate Islamic State, Iraqi intelligence officials say.

The town of Qaim was taken by Iraqi security forces last November. The Falcons sent a team to try to recover Sudani’s corpse. They never found it. – New York Times