The Pakistani army says it has agreed to stop operations against tribesmen accused of sheltering al-Qaeda suspects near the Afghan border.
The army says the agreement is in Pakistan's interests
It says both sides in the South Waziristan area have pledged to resolve all outstanding issues in peace.
The agreement was reached through the mediation of two parliamentarians.
Officials say the move brings an end to fighting in South Waziristan in which the army says more than 100 militants and troops were killed last month.
At the beginning of the operation there were reports that Osama Bin Laden's deputy, Ayman al-Zawahiri, was about to be captured. But no senior al-Qaeda figures have been held.
The BBC's Paul Anderson in Islamabad says the Americans have been depending on heavy military tactics from Pakistan in the area.
American forces have been conducting their own operations on the Afghan side of the border in what they have described as a coordinated "hammer and anvil" operation.
Face to face meeting
Peshawar Corps Commander Safdar Hussain and parliamentarian Maulana Merajuddin both confirmed that a "broad understanding" had been reached to end the standoff in South Waziristan.
The BBC's Rahimullah Yusufzai in Peshawar says that the agreement will be formally announced at a tribal gathering in the Shakai area in South Waziristan on Friday.
Lieutenant General Hussain will attend the meeting, which will be the first time he will come face to face with villagers accused of harbouring al-Qaeda militants.
The delegation of villagers will include five men named as the most wanted Pakistani tribesmen.
Our correspondent says that the agreement is a surprise because both sides were gearing up for another round of fighting after earlier bloody clashes which displaced thousands of people.
The government until now had accused villagers both of harbouring al-Qaeda and Taleban suspects and of taking part in an insurgency against the state.
Lieutenant General Hussain said the agreement was in Pakistan's interest, as tribesmen and soldiers killed in recent fighting in the region were all Pakistanis and Muslims.
He said the villagers would be allowed to return to their villages in South Waziristan once they furnish guarantees of good conduct and agree to live in peace.
But he said that no-one would be allowed to use Pakistan's soil for attacks in Afghanistan or elsewhere and no-one would be allowed to harbour suspected terrorists.
Tribal fighters say they have stopped their hunt for al-Qaeda suspects
He said the government would compensate tribesmen who suffered losses in the recent military operations and whose homes were demolished.
He added that most of the 163 Pakistani tribesmen and Afghan refugees who were arrested in South Waziristan during the military crackdown would be released.
The deal was welcomed by Maulana Merajuddin, the tribal parliamentarian who supports the anti-American six-party opposition religious alliance in the Pakistani parliament.
He said it would allow displaced families to return to their homes, and would help restore peace in the region.
Maulana Merajuddin said the tribals had pledged not to harm Pakistan's interest.
He said that non-Pakistanis found in South Waziristan would be allowed to live peacefully as refugees provided they register with the authorities and offer guarantees not to use Pakistan's soil against any other country.
That would include everyone he said apart from top-ranking al-Qaeda figures such as Osama bin Laden, Dr Ayman al-Zawahiri and Uzbekistan's Islamic leader Tahir Yuldashev.
The tribal elders in South Waziristan have simultaneously announced a suspension of their hunt for al-Qaeda militants and their supporters.