WASHINGTON - President Barack Obama warned on Wednesday of more violence in Pakistan and Afghanistan, but said his government was still committed to defeating al Qaeda, while trying to avoid civilian deaths on those countries.

Obama brought the Afghan and Pakistani presidents to the White House and said both leaders -- heavily criticized by his administration in the past -- had reaffirmed their commitment to the battle against al Qaeda.

But the deaths of dozens of Afghan civilians this week, apparently in U.S.-led air strikes, cast a shadow on the talks.

The road ahead will be difficult. There will be more violence and there will be setbacks, Obama said, with Afghanistan's Hamid Karzai and Pakistan's Asif Ali Zardari at his side.

But let me be clear -- the United States has made a lasting commitment to defeat al Qaeda but also to support the democratically elected sovereign governments of both Pakistan and Afghanistan. That commitment will not waiver and that support will be sustained.

The Red Cross said dozens of Afghans died after U.S.-led air strikes in Farah province this week while local officials said more than 100 civilians may have been killed. If that figure is confirmed it would make it among the deadliest incidents involving Afghan civilians since the fall of the Taliban in 2001.

U.S. Secretary of State Hillary Clinton offered her deep regret for the incident, without implying U.S. responsibility for it. An American official who asked not to be named said it appeared that U.S. bombing may have caused the deaths.

The Obama administration has sharply criticized both Karzai and Zardari in the past, questioning their commitment and capability to tackle the threat from al Qaeda and the Taliban.

Civilian casualties caused by U.S. military operations in both countries, including drone strikes inside Pakistan, are deeply unpopular among Afghans and Pakistanis and have made it harder for both countries' leaders to cooperate with the United States.

We deeply, deeply regret that loss, Clinton said of the civilian deaths as she began a meeting with Karzai and Zardari. Later she called that meeting in some ways a breakthrough and said she was very optimistic the process was making a difference.

Obama announced a new approach to the fight against al Qaeda in both countries in late March, offering more aid but also more than 20,000 extra troops to Afghanistan this year.

We turned a corner, Richard Holbrooke, the U.S. special representative for Afghanistan and Pakistan, told reporters after Obama's brief address. We gave physical reality to the strategic plan.

MY DEMOCRACY ... NEEDS NURTURING

Karzai, whose office said earlier that he called the civilian deaths unjustifiable and unacceptable, thanked Clinton for expressing concern and regret, saying he hoped all civilian casualties could be prevented.

Zardari, who has been under fierce criticism for his response to Taliban militants who have made inroads in the Swat and Buner valleys this year, pleaded for support for his fledgling democracy.

My democracy needs attention and needs nurturing, Zardari said. Pakistani democracy will deliver, the terrorists will be defeated by our joint struggle. Me, my friend President Karzai and the United States ... will stand shoulder to shoulder with the world to fight this cancer and this threat.

Many Pakistanis blame America for undermining democracy in their country for decades by supporting and funding its powerful military, but Clinton said U.S. support for the democratic government was very, very firm.

She also asked for U.S. understanding and patience for Zardari, just eight months into his new job.

He inherited a very difficult and unmanageable situation, she said. I think a little more understanding on our part about what he confronted -- you know, he has successfully navigated some real crises.

VILLAGERS MOURN

Pakistani security forces attacked Taliban fighters in the Swat valley on Wednesday killing at least 64 of them, the Pakistani military said, after the United States called on the government to show its commitment to fighting militancy.

In Afghanistan, villagers mourned relatives buried in mass graves following the bombing in Farah province.

People who survived the bombing of houses packed with terrified civilians told Reuters dozens from one extended family alone had died. They wept as they spoke of orphaned children and burying their loved ones' fragmented remains.

The air strikes, which lasted about an hour, killed 50 members of neighbor Sayed Azam's extended family, he said..

There were Taliban in the area, and fierce fighting during the day but it ended when it was dark. People thought the fighting was over when suddenly bombings began.

Rohul Amin, governor of Farah province, where the bombing took place late on Monday and fighting raged into Tuesday, said he feared 100 civilians had been killed. Provincial police chief Abdul Ghafar Watandar said even more may have died.