A suicide bomber killed at least 32 people at a mosque in northwestern Pakistan on Friday just hours before top U.S. envoy Richard Holbrooke declared the Pakistani mood has turned decidedly against Islamic extremism.

Police say the attack came during Friday prayers at a mosque packed with worshippers in Upper Dir district, not far from Swat Valley where the Pakistani army has been fighting Taliban militants.  

There was no immediate claim of responsibility. But a top Taliban commander has vowed that militants will stage attacks across Pakistan to avenge the government offensive in Swat, where the army has captured a number of key militant strongholds.

As reports of the attack came in, the United State's top envoy to Afghanistan and Pakistan was speaking to reporters in the capital, Islamabad, at the end of a three-day visit to the country. After a series of meetings with officials and a high-profile visit to a refugee camp in Mardan, envoy Richard Holbrooke said he is convinced the Pakistani public will no longer tolerate extremists.

"We found a tremendous change in Pakistan since I was here last just a few weeks ago," he said. "We saw evidence on the ground in the refugee camps and among the leaders of civil society we met here in Islamabad - we found evidence of a substantial change the public mood here in Pakistan against the miscreants, the militants."

Holbrooke also praised the military for its strategic gains against Taliban fighters in the northwest over the past two weeks. But he stressed repeatedly that having "turned the corner" in Pakistan, it was now time to consolidate the gains.  

"The test of this policy is whether the refugees can go home, go home quickly, and return to their normal lives," said Holbrooke.

"And that is going to be - it has to be - a large internationally supported reconstruction effort. We've all seen refugee camps that start out as tent cities and harden into permanent towns, villages. It's happened in every part of the world. This cannot happen here."

Holbrooke said the United States, with Congressional approval, will provide more than $300 million in humanitarian aid to Pakistan, but that no U.S. troops will be deployed here, adding that securing Pakistan was a task for the Pakistani government.  

Holbrooke, whose portfolio includes Afghanistan, was asked if the imminent deployment of 17,000 new troops to southern and eastern Afghanistan, might create more instability along the border with Pakistan as militants try to seek refuge here.

"We are concerned that there may be some spill-over effect as there has been in the past. I've raised it repeatedly in Washington and here and in Kabul. I don't want to be an alarmist here," he said.

"But the one thing that is very important is that as the ISAF [NATO] forces operate in the areas near the Pakistan border that the impact on Pakistan be taken into account at all times, and that the Pakistani security forces are properly aware of the military actions are so they can do what is necessary to protect your border," he added.

Mr. Holbrooke's trip to Pakistan, his third since being appointed a special representative, was clearly designed to show support for the Pakistani army's campaign against the Taliban and to provide money to help deal with the humanitarian crisis that was unleashed as a result of the offensive.

But while Holbrooke's message of support may be welcome, there are still long-standing tensions between Washington and Islamabad that include the Obama administration's decision to continue missile strikes against suspected al-Qaida and Taliban bases in Pakistan's tribal areas, a policy that is deeply unpopular in Pakistan.