Capt. Harith al-Sudani’s wife, Raghad Chaloob, center, and their three children, Riyam, Rawan and Muamal, atop their home in Baghdad.CreditIvor Prickett for The New York Times

BAGHDAD — The driver was sweating as his white Kia pickup truck sped along a rain-slicked Baghdad highway toward a neighborhood 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 the 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 jihadist in the 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. Captain Sudani also gave the agency a direct line to some of the Islamic State’s senior commanders in Mosul.

A 36-year-old former computer tech, he was, agency officials said, perhaps Iraq’s greatest spy, one of a few in the world to have infiltrated the upper reaches of the 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 the 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, the Islamic State might.

Before he left on this, his penultimate mission, he sent his father a text.

“Pray for me,” he said.

Image
The trophy 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.CreditIvor Prickett for The New York Times

Iraq’s counterterrorism intelligence unit, the Falcon Intelligence Cell, may be the most important organization 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 Captain 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 Captain Sudani.

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 the 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.

American 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 American-led military coalition in Baghdad. The Falcons, he said, have diminished the threat of the Islamic State by infiltrating its cells, killing its leaders and terrorists, and destroying its weapons.

Mr. 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

Image
 
Admission to Baghdad University, above, is a coveted opportunity. Mr. Sudani blew it.CreditSergey Ponomarev for The New York Times

Not many people in Mr. 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 out. 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.”

Mr. 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 Mr. Sudani an opportunity, and a purpose.

As the government and the American occupation forces struggled to stem the insurgency in post-Saddam Iraq, Mr. 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.

Image
 
Captain Sudani, when he was training in Lebanon, in a photo provided by his family.

“I searched for them like a man searches for a wife,” he said. “We were ready to take on any challenge.”

Another of Mr. 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.”

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

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

Mr. 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,” General Falih said. “He was a father himself.”

Mr. Sudani was promoted to captain and began training to pass as a jihadist.

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 ability to adopt the Ramadi accent would help his credibility with the group.

But as a Shiite, he was unfamiliar with Sunni rituals and prayer. So he pored over the Quran, memorizing verses favored by jihadists and learning the chants they used for praying and killing.

He would become known as Abu Suhaib, an unemployed man from a predominantly Sunni neighborhood in Baghdad. His mission: infiltrate a notorious Islamic State lair in Tarmiya, 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, Captain Sudani walked into a mosque in Tarmiya 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 recognized his brother’s loping silhouette coming to the prearranged exfiltration spot.

Captain Sudani reported a success — the cell had welcomed Abu Suhaib. He was going back to live with them in Tarmiya.

The Bomb Courier

Image
 
Captain Sudani’s wife, Raghad Chaloob, looking at pictures of her husband.CreditIvor Prickett for The New York Times

His first days with the Islamic State were filled with training on religion and explosives.

A few weeks later, a senior Islamic State official in Mosul called. He assigned Captain 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 Captain Sudani to meet suicide bombers arriving in Tarmiya 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 Captain Sudani as he drove, using jamming equipment to block the signal to the bomb’s detonator, which is usually set off remotely by cellphone. 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 Captain 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.”

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

Image
 
Iraqi army members carry out an operation against the Islamic State in Tarmiya, a hub for suicide bombers near Baghdad. Captain Sudani’s mission was to infiltrate the ISIS cell there.CreditAli Mohammed/Adadolu Agency, via Getty Images

The longer Captain Sudani worked undercover, the greater his risk of exposure.

Still, he chose to continue. General Falih said Captain Sudani told him that he had finally found a purpose in life.

“It was a golden time for us,” General Falih said. “It was a golden time for him.”

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

By mid-2016, there was growing optimism that the group could be defeated.

Captain Sudani’s handlers in Mosul had increased his duties, asking him to scout neighborhoods 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. Captain Sudani said he was at the target neighborhood. The commander told him he was lying, citing his phone’s GPS coordinates.

That may have been the first red flag.

Munaf told his brother that it was time to end his mission. Captain Sudani refused.

By December, however, he was firmly in the Islamic State’s cross hairs.

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 Dec. 19, the group sent a tractor-trailer careening through a Berlin Christmas market, killing 12 and wounding dozens.

On Dec. 31, the Mosul commander told Captain Sudani he had been chosen to take part in a spectacular New Year’s Eve attack, a series of coordinated bombings in multiple cities around the world.

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

Coming Undone

Image
 
Munther al-Sudani, Captain Sudani’s youngest brother, had a tattoo of his brother inked across his chest.CreditIvor Prickett for The New York Times

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.

Captain Sudani assured the caller that he was en route to the target. The handler said he was lying. Captain Sudani frantically struggled to invent an excuse. He told Mosul that he must have made a wrong turn.

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, Captain Sudani was back on the road to the market and parking the pickup 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.

Captain Sudani’s mission was a success.

What he didn’t know was that the 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,” General Falih said later. “We just didn’t realize how much.”

The Setup

Image
 
Iraqi border guard troops patrol the Syrian border near Qaim this year. Captain Sudani may have spent his final days there.CreditIvor Prickett for The New York Times

In early January 2017, the Islamic State called Captain Sudani for another mission. It would be his last.

He was sent to a new location, a farmhouse outside Tarmiya. 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. Captain 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 Jan. 17, he entered the farmhouse.

Just after sunset, the Falcons team alerted General 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 Tarmiya 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 Captain Sudani.

For six months, the Falcons gathered evidence. They discovered the bugs in the Kia truck. Informers suggested that the jihadists had taken Captain Sudani to Qaim, an Iraqi town controlled by the 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 Captain 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’

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

In death, Captain 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.

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, Captain 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 the 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 Captain Sudani’s corpse. They never found it.

Falih Hassan contributed reporting from Tarmiya, Iraq, and Eric Schmitt from Washington.

A version of this article appears in print on