Under a compromise struck this weekend, American troops in Afghanistan will step back to a supporting role in nighttime raids that have infuriated Afghans .

The deal is crucial to determining the part U.S. forces will play in Afghanistan as their numbers gradually diminish over the next few years. President Barack Obama has vowed to withdraw the 30,000 or so surge troops he committed early in his presidency by next summer, and to withdraw American forces entirely by the end of 2014.

The process has been dogged by questions about how U.S. troops will transfer power to their Afghan counterparts and how America will try to ensure stability in Afghanistan after the drawdown ends. American and Afghan officials resolved one of the underlying disputes in early March, when the United States agreed to hand over the control of prisons in Afghanistan.

Now Afghan security forces will also assume control of special operations missions, a category that includes the night raids. While American officials have called the raids an indispensable part of the U.S. strategy to root out militants, the invasive operations have been deeply unpopular with the Afghan people.

Today we are an important step closer to our shared goal of a secure and sovereign Afghanistan, International Security Assistance Force commander Gen. John Allen said at a signing ceremony on Sunday. Together we will realize this vision.

In addition to giving Afghan security forces a lead role in the raids, the agreement brings the operations into the Afghan justice system by requiring that an Afghan court issue a warrant within 72 hours of a raid. Afghan forces can still enlist American troops and delegate the authority to enter Afghan homes as part of the raids.

The war-weary American public has become increasingly disillusioned by the effort in Afghanistan, with recent polls finding that most Americans think U.S. forces should no longer be there. But military experts have warned about the still-tenuous security situation there -- during a recent Senate hearing, Allen said the United States should maintain significant combat power in 2013.