Hundreds of Pakistani troops and pro-Taliban fighters have been killed in the government's attempt to assert its authority in Waziristan as part of the US-led "war on terror".
Under the agreement, the pro-Taliban forces have agreed to stop attacks both in Pakistan and in Afghanistan.
The government will stop air and ground operations in Waziristan and dismantle newly-built checkpoints.
People arrested during military operations are to be released and confiscated property, including weapons, returned.
Malik Shahzada, a member of a tribal council overseeing the negotiations, said: "The agreement will pave the way for permanent peace in the region."
The agreement was signed on Tuesday at a football ground at a college in Miranshah, the main town of the North Waziristan region.
Members of the tribal council watched as a Pakistani army commander, Major-General Azhar Ali Shah, embraced representatives of the fighters after the pact was signed.
Many members of al-Qaeda and the Taliban fled to the semi-autonomous region of Waziristan after US-led forces overthrew the Taliban in Afghanistan in late 2001.
Pervez Musharraf, the Pakistani president, who is due to visit Afghanistan on Wednesday for security talks with his counterpart Hamid Karzai, has said no group could use Pakistan as a springboard for attacks on other countries.
Afghanistan and its allies have long complained the Taliban are able to benefit from havens on the Pakistani side of the long, rugged border.
Musharraf has also vowed to clear foreign fighters from the Pakistani side of the border although the agreement said foreigners could stay in Waziristan, as long as they kept the peace.