Kamal Hamade, the charismatic owner of Taverna du Liban, was known for chatting up his customers and making amazing cake. He was also a man of generosity and foresight.

In a conversation at the Kabul International Airport before Christmas, Mr. Hamade mentioned that his staff was planning to break off and start their own restaurant.

Spying choppy waters ahead for Afghanistan’s transition to full sovereignty and his own business, which had ceased to turn a profit, Mr. Hamade said he wanted to help his employees build their own restaurant and planned to close down Taverna du Liban this year.

Mr. Hamade and several of his staffers were among the 13 foreigners and eight Afghans killed in the January 18 bombing and shooting attack on his restaurant and never had the opportunity to make that graceful exit.

In a way, all of Kabul—all of Afghanistan— faces the same trouble that Taverna du Liban went through.

NATO will leave an ambiguous legacy to stewards who may be no more prepared than the world’s greatest military alliance was to bar the insurgency from the capital.

For most of the Afghan war, Kabul’s relative security has belied the stereotypical image of a conflict zone, but last week’s bombing in a posh neighborhood of poppy palaces and embassies is a reminder that even war-torn Afghanistan stands to lose a great deal if cannot manage to secure itself.

The strike also serves notice to Kabul’s freewheeling expatriates that they may be increasingly targeted by opposition groups—until now mostly focused on nationalist aims—as the West reduces its forces.

In the waning days of the occupation, the bombing raises the specter of the Baghdadification of Kabul.

Baghdad was on the front line of the Iraq war early on. The viciousness of the insurgency there—bombings of the United Nations compound, various embassies, kidnappings and killings of aid workers and journalists—crippled George W. Bush’s efforts to expand his anemic “coalition of the willing.”

Those remaining expatriates in Iraq were driven behind the Green Zone’s high blast walls.

By comparison, Kabul has been protected from battles raging mostly in the south and east of the country by steep mountains and the lack of navigable roads. And wartime Baghdad was never as cosmopolitan as NATO-occupied Kabul.

In Kabul, foreigners are scattered throughout the city in unguarded apartments and guesthouses. In this war-torn Islamic nation, many foreigners—including women—still drive themselves around in “soft cars” without armed guards or chase cars. Many expatriates take taxis to and from work meetings at public cafes and or gatherings at late night bars. Foreigners have gym memberships and do yoga and salsa classes. A few raise children here. They hike and jog on Kabul’s outskirts. They ride motorcycles, own pets and invite friends to backyard barbecues.

In the summer, Kabul’s residential party circuit is legendary, with several drunken bashes a week and some invite lists spanning hundreds of names and scores of nationalities. (In fact, one of the minor casualties of Saturday’s bombing was the Russian embassy’s annual winter party, usually a favorite, but this time hollowed out by security lock-downs after the restaurant attack.)

Good wine is in short supply, but for foodies, Kabul has international cuisine—Japanese, French, Korean, Moroccan, Turkish—nearly everything except reliable Mexican.

And this is where Mr. Hamade fit in with his savory kebabs, French-inflected pastries, and knowing banter. Taverna du Liban was an eatery and a communal living room, but it was also a symbol of the new post-Taliban Afghanistan: global, sensual, sophisticated, and, perhaps, unsustainable.

Until the end of 2003, Baghdad was similar to present day Kabul in that the war was mainly waged outside the capital city gates. The insurgency had not yet coalesced and attacks in Baghdad were sporadic and mainly focused on military and political targets. Things changed, however, on New Year’s Eve 2003, when a suicide attacker drove a bomb-packed vehicle into a pizzeria frequented by internationals, killing eight people and injuring 20 others including several Westerners. The attack seeded the ground for an enduring civil war that reshaped Baghdad’s demographics for good.

From then on, Baghdad itself was Iraq’s main killing zone. Death was random and omnipresent. Bombings targeted bazaars, mosques, schools, and universities. Mutilated corpses floated along the Tigris, piled up at garbage dumps and blocked up sewer canals. Thousands of bodies lay in the capital’s morgue, many of them unclaimed. Three years after withdrawal of coalition forces the battle for Baghdad, and for Iraq, rages on.

As bad as the war has been in Afghanistan, with fatality estimates as high as 62,000 dead, Kabul has not yet seen the kind of warfare Iraq experienced. One reason is that these are much different places with very different dynamics. For example, in Iraq, the occupation by the U.S. disordered a tense Shiite-Sunni equilibrium orchestrated by Saddam Hussein that doesn’t exist in Afghanistan. Nor does Afghanistan have anywhere near the kind of arsenal Saddam Hussein stockpiled in locations U.S. forces inexplicably neglected to secure.

But anyone who cares about Afghanistan should note troubling parallels on the horizon, especially at the close of the Western occupations. As in Iraq, Afghanistan’s government, lulled into complacency by years of ineffectual international aid and rampant corruption, lacks capacity, focus, and credibility with its own people.

As Western occupation drew to a close in Iraq, as is the case in present day Afghanistan, there was no sign that the insurgency had been meaningfully integrated into the country’s governance or economic structures, much less convinced to disarm.

In both cases, local leaders weary of occupiers’ ultimatums and development agencies’ dictates—though not their money—balked at U.S. requirements for security agreements and said American night raids infringed upon their national dignity.

It is hard to say whether the kind of small-scale force of trainers and intelligence operatives envisioned by the U.S.-proposed status of forces agreement in Iraq would have staved off renewed sectarian bloodshed, including the recent takeover of Fallujah by anti-government forces. But it probably could not have been much worse, as the violence there has reached levels not seen since 2008, when U.S. troops were still on the ground.

In Afghanistan, the U.S. is selling a Bilateral Security Agreement that President Hamid Karzai has said he will not sign until after April elections, if at all, despite gaining approval from a council of elders, the Loya Jirga. Here, too, it is unknown whether the proposed force of 8,000 to 10,000 U.S. security personnel will be able to make a difference in a country with an entrenched insurgency, poorer economic prospects than oil-rich Iraq, and neighbors who are either meddlesome or unmotivated by the storms brewing across their border.

In war, violence can be a kind of communication. The weapons deployed, the tactics used, the size of the attacking force, the targets chosen, the timing and chosen witnesses of an attack are all part of the dark grammar of the language of violence.

Last week’s attack on Taverna du Liban in Afghanistan’s most affluent neighborhood by three suicide attackers—a vanguard striker armed with an explosive vest, followed by two gunmen—evinced the opposition’s continued commitment and organization 13 years into the war, on the eve of NATO’s withdrawal.

And it sent the international community a message: The party is over and the war may be just beginning.