WASHINGTON (AP) — Pakistan’s startling accord with Taliban fighters that would impose Islamic religious law on the strategic Swat valley looms as a setback for the Obama administration’s hopes to mount a united front against militants there and in Afghanistan.

The agreement between Pakistan’s government and the growing Taliban forces in the country’s northwest region cemented a truce between the two sides and gave the insurgents dominance in the Swat region by installing a strict regimen of Islamic law amenable to the militants’ authority. The pact was spearheaded by a hard-line cleric sent to the region to negotiate with the Taliban and persuade them to give up their arms.

“It is definitely a step backwards,” said James F. Dobbins, the Bush administration’s first envoy for Afghanistan. “The Pakistanis have to take a stronger line with extremists in the region.”

The war against Taliban rule in Afghanistan seemed won seven years ago. But the Taliban is gaining ground there, U.S. and NATO forces have been unable to reverse the gains, and the outlook appears increasingly bleak.

“We are very concerned about Pakistan and stability,” U.S. special envoy Richard C. Holbrooke said last weekend on a trip to the area.

On Tuesday, President Barack Obama responded by announcing plans to boost the U.S. military presence in Afghanistan by 50 percent, which would send an additional 17,000 troops to a 30,000 force contingent already there.

Dobbins, director of international security and defense policy at the RAND Corp., said in an interview Tuesday that progress will depend on the Pakistani government’s line against the insurgents. “The Pakistanis have to take a stronger line with extremists in the region,” he said.

He said there were also some positive developments in Afghanistan. Among them: “The United States has more international support than it had in the war in Iraq and all of Afghanistan’s neighbors consider President Hamid Karzai as legitimate and want his government to succeed.”

However, Dobbins said, “There is no guarantee of success.”

“We are going to have to get used to two steps forward and one step backward, at best,” he said.

U.S. officials were hesitant to comment publicly on the Pakistan-Taliban deal, which would impose Sharia religious law on the Swat valley, a scenic swath of the northwest tribal region frequented by travelers, but also close to border areas that have become militant strongholds.

A U.S. defense official characterized the deal as a “negative development,” but officials were more cautious in public statements.

“What is, of course, important is that we are all working together to fight terrorism and particularly to fight the cross-border activities that some Taliban engage in,” Gordon A. Duguid, the department’s deputy spokesman, said earlier this week. On Thursday, Duguid added that U.S. officials were in discussions with “the government of Pakistan, and, you know, we’ll see what the results of their policy will be.”

Also hesitant to offer a judgment, Secretary of State Hillary Rodham Clinton said in Japan that the agreement between Pakistan and Taliban still needed to be “thoroughly understood.”

NATO, which has 55,000 troops in Afghanistan, took a tougher line. The truce between Pakistan and Taliban in Swat “is certainly reason for concern,” NATO spokesman James Appathurai said in Brussels. “We should all be concerned by a situation in which extremists would have a safe haven.”

“Without doubting the good faith of the Pakistani government, it is clear that the region is suffering very badly from extremists and we would not want it to get worse,” he said.

Rick Barton, a senior analyst at the Center for Strategic and International Studies, said Tuesday that the “tame way we are responding is appropriate. There are many serious unknowns.”

Still, spokesman Duguid noted that Islamic law is within the constitutional framework of Pakistan, and Barton said an agreement to bring Shariah law to the one-time ski resort area in the 1990s did not pan out.

Apart from the conflict, the impact on civilians could be harsh under strict interpretation of Shariah law.

“The government is reneging on its duty to protect the human rights of people from Swat Valley by handing them over to Taliban insurgents,” said Sam Zarifi, Amnesty International’s Asia-Pacific director.