The central government and tribal elders signed a peace agreement on Tuesday that will allow militants to operate freely in one of Pakistan's most restive border areas in return for a pledge to halt attacks and infiltration into Afghanistan.
The deal is widely viewed as a face-saving retreat for the Pakistani Army, which has taken a heavy battering at the hands of the mountain tribesmen and militants, who are allied with the Taliban and Al Qaeda. But the government may have in effect ceded the militants a sanctuary in the area, called North Waziristan.
In one of the most obvious capitulations since it began its campaign to rout foreign fighters from the area, the government said foreigners would be allowed to stay if they respected the law and the peace agreement. Osama bin Laden and other leaders of Al Qaeda are believed to be among the foreigners who have taken refuge in the area.
The agreement, reached a day before a visit by President Pervez Musharraf to Afghanistan, will be presented by the government as proof of Pakistan's effort to deal with militancy and terrorism. Relations with President Hamid Karzai of Afghanistan have been strained this year as the insurgency in southern and eastern Afghanistan has swelled.
The military moved into the tribal areas three years ago in an effort to curb militants who were using the territory as a base for attacks on Afghanistan, but it has faced fierce resistance, losing some 500 soldiers in the fighting.
Hundreds of civilians and militants have also been killed, and Afghanistan has been vocal in blaming Pakistan for allowing insurgents to use the area as a rear base.
In the agreement, signed by seven representatives of the Taliban council in North Waziristan, the militants pledged, ''There will be no cross-border movement for militant activity in neighboring Afghanistan.'' They also vowed to stop attacks on government and security forces.
For its part, the government agreed to cease any ground or air operations and to resolve issues through local customs and traditions. The tribal areas have traditionally been nearly autonomous.
Pakistani soldiers immediately began to leave checkpoints in the region, handing them over to the local tribesmen.
The government also agreed to release all detainees and the militants pledged not to attack government forces or property or set up a parallel administration. Both parties agreed to return weapons and other equipment seized during the fighting.
The agreement appeared similar to an earlier one signed in South Waziristan, which essentially allowed the militants to remain armed and at large in return for not attacking the Pakistani military.
A spokesman for the militants, Abdullah Farhad, denied in a telephone call from an undisclosed location that there were any foreign militants in North Waziristan, and said the government should provide evidence of their presence.
''Why should we bother if they are not here,'' he said, speaking of foreign fighters.
The deal was brokered by a grand tribal jirga, or assembly, set up by the governor of the North-West Frontier Province on July 20, after the militants declared a unilateral ceasefire. Turning to a jirga was an admission by the government that it could not win control of the region militarily.