US President Barack Obama has said after meeting his Afghan and Pakistani counterparts that they are united in the goal of defeating al-Qaeda.

After "extraordinarily constructive" talks, Mr Obama said the aim was to "defeat al-Qaeda" and its allies.

He vowed to try to avoid civilian casualties in the conflict, and pledged greater resources to aid both nations.

Meanwhile, fighting continues in north-west Pakistan, where the army is trying to dislodge Taleban militants.

Thousands of civilians are fleeing as troops use helicopter gunships and warplanes to reverse a Taleban advance in the Swat Valley region.

In Afghanistan on Tuesday, dozens of civilians are thought to have died in US air strikes on Taleban targets.

US Secretary of State Hillary Clinton said she "deeply, deeply" regretted the deaths, adding that the US would work hard to avoid such "loss of innocent life".

'Solid support'

The bottom line at the summit was more American troops for Afghanistan and more aid for Pakistan, with the Obama administration deepening its involvement in the search for stability, the BBC's Kevin Connolly reports from Washington.

Mr Obama said Afghan President Hamid Karzai and Pakistani President Asif Ali Zardari fully appreciated the gravity of the security threats posed by militants.

America, he said, was on the side of people in Pakistan and Afghanistan and had a comprehensive strategy for the region, with civilian and military components.

He said the insurgency must be met with a positive programme of growth, so that Pakistanis and Afghans could pursue the possibility of a better life.

President Obama said he expected more setbacks and violence to come, but there was a lasting commitment to defeat al-Qaeda.

The US would, he added, offer unwavering support to the governments of both Pakistan and Afghanistan.

"We have learned time and again that our security is shared," Mr Obama added. "It is a lesson that we learned most painfully on 9/11, and it is a lesson that we will not forget."

Senior US officials have expressed uncertainty over the commitment of the military in Pakistan, a nuclear power, to defeating militants based in its border region.

Speaking after talks with Mrs Clinton, President Asif Ali Zardari said Pakistan would help Afghanistan and the US to fight the threat posed by the Taleban and al-Qaeda.

"For no matter how long it takes and what it takes, democracies will deliver, my democracy will deliver," he told reporters.

"People of Pakistan stand with the people of the United States and the people of Afghanistan."