POLITICS is never dull in Pakistan. Recently, it has been inspirational too. Last week, I watched people flock to the home of Iftikhar Mohammed Chaudhry. A tense standoff between the government and a coalition of opposition groups over Chaudhry’s reinstatement as chief justice of Pakistan’s Supreme Court had finally been resolved.

A cross-section of Pakistan’s diverse society gathered by the thousands on the lush, manicured lawn of the chief justice’s official residence to celebrate — young and old, men and women, religious and secular, rich and poor. Lawyers in their black suits, the signature uniform of Pakistan’s democratic revolutionaries, danced the “bhangra” as drums sounded and chants about freedom and justice filled the air.

It was a noisy victory party for democracy and the rule of law, and it contained a positive message about Pakistan for the world.

Since Sept. 11, 2001, the very name of Pakistan has been synonymous with the West’s deepest, darkest fears: A nuclear-armed state with a predominantly Muslim society struggling to control an insurgency inspired by the most oppressive and puritanical of religious impulses. That has generally been the explanation for the billions of dollars in military aid the United States has given to Pakistan Army. (The New America Foundation estimates that in 2006 and 2007 alone, the US gave $3.5 billion in military aid to Pakistan Army, the most powerful institution in an institutionally weak state.)

The dark view has only been underlined by the violence that has engulfed Pakistan — the murder of its most celebrated politician, former Prime Minister Benazir Bhutto, in a suicide attack at the end of 2007; the Marriott Hotel bombing in Islamabad; Pakistan’s alleged role in the attacks in Mumbai, India, in November; and the attack on Sri Lankan cricketers in Lahore this month.

But Chaudhry’s reinstatement represents the final act of a popular revolt that should be as meaningful to the West as the violence and fanaticism. He was not the first judge to be fired by an autocrat in Pakistan, but his removal by former President Gen. Pervez Musharraf was met with unprecedented public protests. Ultimately, the protesters won and Musharraf was forced to step down.

President Asif Ali Zardari emerged as the head of the Pakistan People’s Party (PPP) and Musharraf’s unlikely replacement. He soon reminded people of Musharraf by banning pro-Chaudhry protests, arresting opposition leaders, trying to shut down private news channels and refusing to reinstate the chief justice. Last week, fearing a fate similar to Musharraf’s, Zardari finally caved.

The US role in all of this was glaring by its absence. It has preferred to invest heavily in Pakistan Army for more than three decades. According to noted military analyst Ayesha Siddiqua, the long experience of military rule combined with the domination of civilian politics by a small group of elites have stunted the institutional development of a democratic culture in Pakistan.

Not surprisingly, when lawyers and ordinary citizens took to the streets in 2007, there was mostly collective silence from Pakistan’s key Western allies. President George W. Bush went so far as to describe Musharraf as “a solid friend” who deserved the United States’ continued support. Although the US spoke of spreading democracy to the Muslim world, it did nothing publicly to help this most democratic of peoples’ movements.

Recently, positive signals have begun to emanate from Washington, D.C. Sen. John Kerry, chairman of the Foreign Affairs Committee, has called for a tripling of US nonmilitary aid to Pakistan — about $7.5 billion over the next five years. More than the money, however, the US government has to start listening to the people of Pakistan.

Despite millions of dollars spent by the State Department on opinion polls in Pakistan, there has been a catastrophic failure to understand the local mindset. As recently as last week, that failure was in evidence when President Barack Obama’s envoy for Afghanistan and Pakistan, Richard C. Holbrooke, praised Zardari, of all people, for his “statesmanlike” decision to reinstate the chief justice.

Where was the praise for the chief justice who had braved two authoritarian presidents, or for the hundreds of thousands of ordinary Pakistanis who risked assault and arrest to support him? To ordinary Pakistanis, it sent the familiar signal that the United States supports the autocrats over the people. The Chaudhry victory will not solve Pakistan’s problems. But by demonstrating the importance of functioning and accountable institutions, the country’s lawyers may well have found an opening for the long road out of the country’s present hell.