Jon Finer spent 18 months covering the Iraq War as a foreign correspondent for The Washington Post. He was chief of staff and director of policy planning for Secretary of State John Kerry.

Then-Col. H.R. McMaster works out briefly before meeting with Iraqi officials in Tal Afar, Iraq, in early 2006. (Photo by Tom Ricks/The Washington Post)

On the eve of his biggest mission, in a career marked by hard jobs done well, Col. H.R. McMaster explained to me how the United States could win the battle for the city of Tal Afar and, eventually, the Iraq War.

It was a bold belief at the time: August 2005, the dog days of a long, bloody summer, during which a brutal insurgency had plunged Iraq to the brink of civil war. American casualties mounted, and there was no clear strategy for turning the tide.

McMaster was about to give the order to launch Operation Restoring Rights, which would become the conflict’s second-largest military campaign, after the liberation of Fallujah a year earlier. But Tal Afar, McMaster knew, would in some ways be even more complicated — demographically (a mix of Sunni Turkmen, Shia Arabs and Kurds), geographically (less than 100 miles from a terrorist crossing point into Iraq from Syria) and politically, as the new Iraqi government was struggling to find its feet and the George W. Bush administration’s war of choice seemed to be spinning out of control.

In contrast with Fallujah, heavily covered by the international press, the Tal Afar offensive was relatively low profile, in part because it coincided with, and was overshadowed by, the landfall of Hurricane Katrina. As a Baghdad correspondent for The Washington Post, I was one of two Western reporters accompanying McMaster’s 3rd Armored Cavalry Regiment, assigned to a platoon called Eagle Troop for almost three weeks. From before dawn until well after dark, we swept through the city — house by house, block by block, often under fire that couldn’t be located — in search of terrorists who had made it their home.

When McMaster (who is now a lieutenant general) was named President Trump’s new national security adviser, I retrieved from a closet three dusty spiral notebooks from that time. They reminded me of the fatally flawed hand he was dealt and the flicker of promise he produced, seized upon by an administration desperate for good news and yet soon snuffed out.

“The good people of this city have been under assault from the enemy for months,” McMaster told me in our first meeting, before walking me through Tal Afar’s toxic mix of sectarian violence, illiteracy, terrorist infiltration and inter-ethnic tension. “You have tribal rivalries that go back 200 years. You have Turkmen Sunnis who feel complete evisceration from the Kurds in the north and the Shia in the south. You have all of the problems of Iraq here, in microcosm . . . it all comes together in this little town.”

Tal Afar, which before the 2003 U.S. invasion was home to some 200,000 people, has the dubious distinction of being one of the most frequently “liberated” cities in Iraq, to use the U.S. military’s term of art; which, of course, also means it has been among the most often conquered. After the invasion, it was one of the earliest cities to be taken by insurgents. In 2004 the U.S. Army pushed them out but left only 500 troops behind, and by 2005 Tal Afar had been recaptured.

I was tipped off about the coming offensive by a Washington colleague. You will like McMaster, he told me. It turned out everyone in the media liked McMaster, starting with his rare résumé, well-chronicled in recent days, replete with both soldierly valor and intellectual cred. He also has a flair for pungent comments tailor-made to be quoted.

The morning the operation began, he recounted how insurgents had recently murdered a child, placed an explosive in his body and then detonated it when his father came to retrieve him. “The greatest privilege of a professional soldier,” he said, “is to have the opportunity to kill these people.”

Bravado aside, however, killing terrorists was not McMaster’s priority, he said. He had a plan to make Tal Afar the proving ground for a new way of fighting the war, which the U.S. government was only starting to grudgingly acknowledge as an insurgency. It was the dawn of a short-lived age when “counterinsurgency doctrine,” a niche specialty among a certain set of soldier-scholars, became the Washington zeitgeist.

McMaster brought to Tal Afar as an adviser an Army reservist named Ahmed Hashim, a bona fide expert with a doctorate in security studies from the Massachusetts Institute of Technology. Hashim was candid when I asked how he thought the war was going. “The U.S. response is not that different from a lot of countries faced with insurgencies: deny it, downplay it, disparage it. It’s not an effective strategy,” he said.

As McMaster explained it, the military needed to focus not just on killing terrorists but on protecting and winning over civilians, so they would not allow the terrorists to return. This meant taking greater risks with American lives than the Pentagon had accepted to that point. He described what he called the “lessons” he would implement:

First, “if we go in and fight and then reduce our presence, the enemy will move to where there are insufficient security forces, because the Iraqi security forces can’t withstand them yet.”

Second, “you have to defeat the enemy’s campaign of intimidation over the population by providing security for people who cooperate with you. You cannot allow retribution.”

Third, you need to “clarify your intentions to people by developing relationships, by action, by dialogue with people and by addressing local grievances.”

Fourth, “this means being out in the city. We could stay in our F.O.B. [Forward Operating Base] and eat mini pizzas and ice cream and redeploy in a year, but that won’t win the war.”

Fifth, “do everything you can to minimize destruction. If that happens, it’s the enemy’s fault. We’re not booby-trapping buildings, putting explosives in the ground, sniping indiscriminately. We’re fighting the people doing that. We don’t want to kill this city, we want to bring it back to life.”

I spent the next 15 days with McMaster’s troops as they fought their way to what was supposed to be the al-Qaeda stronghold, a dense tangle of ancient streets in a neighborhood known as Sarai. McMaster kept in touch with me by phone, which was rare for a commander during an intense operation — and a sign of his media savvy. He called to give me updates on the operation. He called to apologize after one of his sleep-deprived soldiers shot at me twice after mistaking my flak jacket, which was a different color than those issued by the Army, for a suicide vest. (We agreed it could have been worse.)

He also called to complain about my coverage, specifically my use of the label “peshmerga” to describe the Kurdish forces he had bused in to do the heaviest fighting. McMaster asked that I refer to them as the Iraqi army, which, technically, they were. But their uniforms and vehicles were adorned with Kurdish flags, not Iraqi ones. They spray-painted Kurdish slogans on the sides of buildings. Their presence had the potential to alienate the majority Turkmen and Arab population, which saw them as a threat. In the end, I told McMaster I would happily ask the Kurds who they thought they were fighting for and go with whatever they said. He laughed and eventually dropped it.

The only time I saw McMaster on the battlefield came as the operation was winding down. He and his Iraqi counterpart stopped by to watch Iraqi troops practice storming buildings. For training purposes, they chose a structure with an Iraqi flag plastered across the front wall, which meant it had already been checked for anything dangerous.

Seconds after the Iraqis charged through the door, an explosion erupted inside, followed by peals of gunfire. Two soldiers stumbled out, carrying a third, whose blood was soaking through his uniform on his right arm, abdomen and leg. McMaster ran over and put his hand on the wounded man’s shoulder. “You’re going to be fine,” he said, as a medic bandaged the Iraqi’s wounds and injected him with morphine. “You’re going to be okay.”

Maybe an insurgent had sneaked back into the building after it was cleared. Maybe it had never been cleared at all. Either way, the American trainers were furious and embarrassed. Most important to McMaster, though, was what happened next. The Iraqi troops, who at an earlier point in their training might have panicked and refused to fight, regrouped and went looking for a man they thought they saw throw a grenade before fleeing out a back door.

An hour or so later, after another firefight a couple of blocks away, the call came over the radio: “I have two AIF KIA” — anti-Iraqi forces killed in action. The Iraqis said they got their man, though it was difficult to know for sure.

By the relatively low standards of that phase of the war, Operation Restoring Rights was a success: Insurgents were either killed (a small number), captured (a larger number) or fled the city (the vast majority, denying the soldiers the showdown they sought). McMaster’s troops took a modest number of casualties. He seemed to have thought more deeply about the challenge U.S. forces faced, and inspired greater fealty among his charges, than any other commander I saw while embedded with the U.S. military in Iraq.

“Counterinsurgency tactics dealt the insurgents of Tal Afar a huge blow,” he told me before I boarded a C-130 to Baghdad. “We have broken the fear that dominated this place.” Residents who remained in the city walked freely in the streets for the first time in months. “In a few days we will ask the civilians to return,” said mayor Najim Jabouri, who had been brought by the U.S. from Baghdad to govern the divided city.

Still, according to the standards McMaster himself had laid out, the operation was far from perfect. U.S. forces were more restrained than I had observed elsewhere, but they tore apart hundreds of Iraqi homes they entered, often after breaking down or blowing through doors, shouting in English at terrified residents, and leaving a wake of crying women and children and seething men. Every night they evicted families so they would have a place to sleep. As I wrote at the time, they detained people on little more than the say-so of anonymous informants who may have merely had an ax to grind.

On the eve of the final assault on the city center, we stayed up late, the skies alight with cacophonous strikes from Apache helicopters. The next day, many buildings had been reduced to rubble, though not on the destructive scale of Fallujah. Before Eagle Troop entered Sarai, what we thought was a firefight broke out. U.S. troops unloaded hundreds of rounds in quick bursts over 45 minutes. When the radios called for a cease-fire, it turned out the shooting was going in only one direction.

None of this was unusual in the foggy urban fighting that U.S. forces were asked to do in Iraq. Hashim, the skeptical academic who had been integral to designing the strategy, proclaimed himself satisfied, though with some hesitation. “The problem is, what happens when this unit leaves?” he lamented. “It’s only a one-year vision, and then we rotate out.”

That turned out to be a prescient question.

For at least two years after I left Tal Afar in mid-September 2005, Iraq continued to disintegrate. The city that got a shout-out from President Bush (“the outlines of the Iraq we’ve been fighting for”) descended back into insurgency. By mid-2006, Tal Afar was awash in the sectarian violence that had engulfed much of Iraq. A spate of suicide attacks culminated in early 2007, when two truck bombs killed 152 people and wounded more than 300 others.

The U.S. troop surge in 2007 and 2008 employed nationwide the tactics pioneered by McMaster, who was back in Iraq to advise commanding Gen. David Petraeus. Though the political chasm between Shiite rule and Sunni grievance remained unresolved, Tal Afar benefited from reduced violence across the country.

It didn’t last. In June 2014, almost three years after U.S. combat forces left the country, Tal Afar was one of the first cities captured by the Islamic State as it rampaged across northern Iraq. Reports soon emerged of summary executions on the same streets McMaster’s troops had patrolled. The cause of Iraq’s most recent disintegration is hotly debated. Critics of President Barack Obama blame the troop drawdown he oversaw, although the leading alternative was a much smaller force, with a non-combat mission. Iraqi leaders’ unwillingness or inability to govern inclusively — a perhaps inevitable result of the sectarianism America’s invasion unleashed — played a role, as did the unexpected eruption of an even more brutal conflict next door in Syria.

Today, much of Tal Afar remains under the control of the Islamic State, though Iraqi forces, backed by the United States, have begun to liberate it yet again.