Pakistan and Afghanistan have to fight "the scourge of terror and extremism" together, Pakistani President Pervez Musharraf has said on a visit to Kabul.
Relations between the two countries have been strained
Speaking alongside Afghan leader Hamid Karzai, Gen Musharraf said the nations should have "brotherly" relations.
Ties have been frayed by Afghan claims that Islamabad has not done enough to stop cross-border Taleban raids.
Separately, visiting Nato Secretary General Jaap de Hoop Scheffer has said the anti-Taleban fight "will be won".
Nato forces have suffered losses in Afghanistan in recent weeks and a major Nato-led offensive is still under way in southern Kandahar province.
After the two presidents held talks in Kabul, Gen Musharraf told a joint news conference: "The key obstacle in the area... is the scourge of terrorism and extremism. This is the scourge that we have to fight."
Mr Karzai said: "I am very happy today that the president of Pakistan assured me that he will try to get rid of this disease from the region."
Gen Musharraf said the two nations must fight the "Talebanisation" of society.
The leaders have argued in the past about how to fight militants but Gen Musharraf said: "If we don't trust each other, there is no moving forward. The only course left is to have trust - kill mistrust, don't blame each other."
Gen Musharraf's visit comes after Pakistan signed a pact with pro-Taleban militants on the Afghan border.
He warned that any Pakistani militants breaking the peace deal would be met with renewed military action.
The North Waziristan accord calls on tribesmen to expel foreign militants and end cross-border attacks in return for a reduced military presence.
Many observers doubt the accord can be enforced, pointing to similar deals in neighbouring South Waziristan which strengthened the hand of Taleban supporters.
Relations between the two neighbours have been strained over the question of infiltration.
Pakistan ended support for the Taleban in 2001 and has denied accusations that Taleban fighters launch attacks from safe havens within Pakistan.
In February, Afghanistan issued a list of 150 Taleban suspects living in Pakistan whom it said it believed had carried out attacks in Afghanistan.
Pakistan said the information was outdated, which Mr Karzai denied.
The two countries share a 2,250km (1,400-mile) mountainous border which is extremely difficult to patrol.
Test of Nato
Earlier on Wednesday, Mr Karzai signed an accord with Nato's Mr de Hoop Scheffer to boost security and development.
Mr de Hoop Scheffer (L) and Mr Karzai sign a development accord
It came after Nato had said more than 50 Taleban fighters were killed on Tuesday in the major Nato-led offensive in the Panjwayi district in the southern Afghan province of Kandahar.
However, the fighting is less intense than over the weekend when Nato said 200 militants were killed - a figure disputed by the Taleban, which said many of the casualties were civilians.
Nato took over command of military operations in southern Afghanistan from the US a month ago.
Mr de Hoop Scheffer said: "The spoilers are testing out Nato to see if Nato is as robust as the [US-led] coalition. The answer as we now see is: 'Yes'."
He said Nato troop levels were sufficient, but that they could be increased in the future if the mission demanded it.
"We should win, because not winning means Afghanistan becoming a failed state again," he said.
But in another example of the violence wracking the country, a suicide bomber attacked a car in Yaqubi in the eastern province of Khost on Wednesday, killing the teacher and civil servant seated inside.
One report suggested the bomber may have mistaken the vehicle for that carrying a local district chief.