Seized by Islamic State in the summer of 2014, Mosul became the terrorist group's top prize in Iraq. But it was the much smaller city of Tall Afar, 60 miles from the border with Syria, where the group had its deepest roots.
The hometown of some of Islamic State's top figures, it fell to the extremists five days after Mosul and became an essential outpost for the militants between their territories in Iraq and Syria.
The "astonishingly brutal nature of the sectarian conflict" that had raged there since the U.S. invasion in 2003, a researcher at the Wilson Center wrote last year, had given Tall Afar the reputation of being Islamic State's "very own heart of darkness."
Yet it took only eight days this month for Iraq's military to end the extremists' reign there, with different branches of the armed forces breaching Tall Afar from three sides before racing to the city's center.
By Sunday, commanders had announced their complete control of the city and were chasing fleeing militants seven miles away in the village of Ayadhiyah. Clashes there were ongoing Monday, local news outlets reported.
In the run-up to the campaign, military planners had feared a repeat of the fight for Mosul, considered to be the largest urban conflict since World War II. That offensive, which ended in July, was a grueling close-quarters brawl in which troops flushed out the extremists from among civilians cowering in their homes.
The fighting leveled wide swaths of Mosul, the second-largest city in Iraq with a prewar population of more than 2 million, and tens of thousands of civilians and soldiers were killed and wounded.
Tall Afar is a smaller city, but was thought to have anywhere from 10,000 to 50,000 inhabitants still inside, according to the U.S.-led coalition that provided air support. The United Nations said they were living in horrific conditions under a crippling siege by government forces that had surrounded the city.
The estimated 1,000 militants had been given "no choice but to surrender or die," according to Iraqi Prime Minister Haider Abadi in a speech at the start of the offensive, and were expected to put up a fierce resistance.
It was to be a politically complicated battle as well. Tall Afar's population was dominated by Sunni and Shiite Turkmens, an ethnic minority.
Islamic State espouses an extreme form of Sunni Islam that views Shiites as apostates who are to be killed, and the terrorist group did just that after it took over the city.
That raised fears that a Shiite group known as Hashd al Shaabi, or Popular Mobilization Forces, would kill Sunni civilians trapped in the city and draw surrounding nations deeper into the conflict.
The Turkish government, which dispatched troops to the area last year to help train local fighters for the Mosul campaign, threatened to intervene to protect Sunnis. Saudi Arabia and Jordan expressed concern that Hashd's participation in the battle would cement Iranian influence in the region and give Tehran another waypoint along a supposed land corridor stretching to Lebanon.
But the fight to take back Tall Afar proved far easier than expected.
Iraq's elite Counter-Terrorism Service, the U.S.-trained force that spearheaded the offensive, killed 225 militants, while the federal police killed 17, officials said.
"The enemy's morale is low … because of the speed of operations," Brig. Gen. Haidar Obeidi, a commander in charge of airstrikes, said in an interview with local media on Sunday, echoing statements by other soldiers who said the operation had been relatively easy.
Military intelligence sources said they had received information of a deal arranged beforehand in which some of the forces besieging the city had given the extremists safe passage into Turkey before the offensive.
But the most important factor affecting the pace of operations was the small number of civilians in the city, Obeidi said in a phone interview Monday.
Unlike Mosul, where residents had been told by the government to remain in the city, Tall Afar had largely been emptied beforehand, with the government reporting that more than 40,000 people had left the city since April.
One mystery was the fate of hundreds of Yazidi women who had been kidnapped by Islamic State in August 2014 and used as sex slaves. They were not in the city as activists had hoped
Douglas A. Silliman, the U.S. ambassador to Iraq, congratulated Iraqi forces for "the very quick progress in Tall Afar" as well as "the great victories" they had achieved in removing Islamic State from 90% of the country.
"We are deeply thankful, as the United States and the rest of the world, for the sacrifices of the Iraqis in this battle," he said in an interview with a media representative of the Iraqi Ministry of Defense broadcast on social media on Monday.
With the campaign finished, troops are expected to continue their march southeast toward the town of Hawija, which is still in the hands of Islamic State, as well as Anbar, where it maintains a presence near the Iraqi-Syrian border.
Bulos is a special correspondent.