Pakistan's President Pervez Musharraf has addressed a "peace jirga" in Afghanistan, calling for a better mutual trust between the two countries.
Gen Musharraf said both countries had to work together to "defeat the forces of extremism and terrorism".
He signed a six-point declaration with Afghan President Hamid Karzai pledging to continue the "war on terrorism".
Relations between the countries have been strained over the resurgence of the Taleban in Afghanistan.
Gen Musharraf acknowledged that Pakistan's tribal regions had harboured Taleban support and he pledged to prevent these elements from creating trouble.
Addressing about 700 tribal leaders from both nations, he spoke of the need to reach out to those who backed the Taleban but were not necessarily extremists.
He asked Afghans to convince their "estranged brothers and sisters" to help rebuild their country.
The declaration signed by the two leaders called for the suppression of the illegal drug trade and the promotion of economic projects in their border areas.
They also pledged to set up a smaller 50-member jirga to meet regularly and entrench security measures as well as promoting dialogue with opposition figures.
The BBC's Charles Haviland in Kabul says the presence of Gen Musharraf at the jirga was a major boost for the gathering after he missed the four-day event's opening session on Thursday.
Gen Musharraf adopted a conciliatory tone and spoke of the strong ties between the two countries.
He said the rise of militancy in the region was hampering efforts to improve prosperity while the rest of Asia forged ahead.
He told the audience: "Our societies face a great danger [from] a small minority that create violence and backwardness.
"These forces are disrupting peace and harmony, impeding our progress and development."
Mr Karzai told the gathering that he was committed to building trust between Afghanistan and Pakistan.
"I pray for the good relationship between these nations," he said.
"The result of the jirga was excellent. I am very happy we had respectful leaders from both sides in this jirga."
Both countries are allies of the US and say that they want to quash terrorism, but many Afghan officials accuse Pakistan of harbouring Taleban and al-Qaeda fighters.
Islamabad denies this, pointing out that it has arrested senior militants and is battling its own Taleban threat in its tribal areas.
However, tribal elders from Waziristan, the Pakistani region from which much of the instability stems, refused to attend the peace summit.
They said that without Taleban representatives present at the talks no solution could be found.