Watching the horrific Mumbai terrorist attacks play out on television made me recall something Pakistan's foreign minister told me six months ago.

Better relations with India "are a top priority," Makhdoom Shah Mehmood Qureshi said while on a visit to the Philadelphia area. "There is a large constituency on both sides that wants normalization.

"There may be hiccups," he added, "but we will forge ahead." Indeed, Qureshi was visiting Delhi and trying to advance bilateral ties when the terrorists hit Mumbai.

What happened in Mumbai was a blunt attempt by militants to destroy efforts by Pakistan's elected government to forge a new relationship with the country's archenemy. Leaders in both Delhi and Islamabad know this, but popular pressures could undermine reason. One of America's biggest challenges - at a time of presidential transition - will be to prevent post-Mumbai tensions from pushing these nuclear-armed states toward war.

"The terrorists' target is Pakistani democracy as well as Indian democracy," Husain Haqqani, Pakistan's ambassador to Washington, told me. "What do they want? They want to undermine the peace process and have mayhem instead."

Those who organized the attack - mounting evidence points to a Pakistani group called Lashkar-e-Taiba - knew Pakistan's president, Asif Ali Zardari, has made stunning overtures to India since he took office. Few expected such bold moves from Zardari, who is tainted by past charges of corruption and gained power only after his wife, former Prime Minister Benazir Bhutto, was assassinated.

Yet Zardari has renounced any first use of nuclear weapons and called for an economic union with India. Last month, he dissolved the political wing of Pakistan's premier intelligence agency, the ISI. And he has moved troops from Pakistan's Indian border to its Afghan border to fight Islamist militants who want to topple the Kabul government and his.

No one knows, however, whether Pakistan's powerful military and ISI will follow Zardari's lead. The army's raison d'etre has been to fight India. And the ISI has nurtured such groups as Lashkar-e-Taiba, which was founded to attack India over Kashmir but is now linked with Taliban and al-Qaeda militants on the Afghan border. Many suspect that ISI elements still have ties to Lashkar-e-Taiba, a group also blamed for an attack on India's Parliament that nearly caused a war in 2001.

The terrorists probably were worried that times were changing. Pakistan's business class is tired of the conflicts on its border, which keep its economy in turmoil while India prospers.

If India and Pakistan could normalize ties and resolve the Kashmir dispute, Pakistan's government could turn full attention to crushing the militants on the Pakistan-Afghanistan border. What better way for terrorists to upset this hopeful scenario than to wreak havoc in Mumbai?

Indians are rightfully furious and want their military to hit back at Pakistan, which could end Zardari's plans for reconciliation. If the Indian government doesn't satisfy its public, it could lose upcoming parliamentary elections to more hawkish parties.

So how can the terrorists be prevented from achieving their aims?

Answering that was the mission of Secretary of State Condoleezza Rice, who visited both countries last week, and of a quick trip to Islamabad by Mike Mullen, chairman of the Joint Chiefs of Staff. They reportedly urged Pakistan to arrest and possibly extradite suspects who were linked to the terrorists by cell phone calls.

It is no longer tolerable that Lashkar-e-Taiba front organizations hold huge rallies across Pakistan even though the group has been on the U.S. and Pakistani terrorist lists since 2003.

Zardari has promised a crackdown once he is given the evidence. One Pakistani official told me, "Lashkar-e-Taiba is going to get it in their butt from the state of Pakistan. There will be hell to pay."

This won't be easy. Lashkar-e-Taiba has popular support because it fights for Kashmir. Many Pakistanis believe there is a secret U.S.-Indian cabal to dismember their nation. Zardari will have to convince his public that the militants are the real threat and show India he means business.

Meantime, President-elect Barack Obama should name a special emissary to South Asia who can talk to both sides and also make both sides talk to each other. The United States will have to press Pakistan's army chief and new ISI head to change focus to the militants who seek to undermine the state.

The terrorist massacre in Mumbai has raised new dangers, but it also created new opportunities by clarifying the options facing both countries. Either Pakistan and India do what's necessary to keep the peace process alive, or the terrorists have won.

E-mail Trudy Rubin at trubin@phillynews.com.