The Afghan and Pakistani presidents have agreed to increase co-operation against terrorism during talks in the Turkish capital, Ankara.
The talks, hosted by Turkey, are aimed at easing tense bilateral ties
Hamid Karzai and Gen Pervez Musharraf pledged "to deny sanctuary, training and financing to terrorists".
They also promised better intelligence sharing between their two countries.
Mr Karzai and Gen Musharraf have frequently been at odds over how to combat a resurgent Taleban along the two countries' volatile border.
The talks came amid an upsurge in violence in Afghanistan.
Nato-led forces and Afghan troops said they killed scores of Taleban fighters in the western province of Herat, and UK forces launched a major offensive in Helmand in the south.
At the talks, which also included Turkish President Ahmet Necdet Sezer, Mr Karzai and Gen Musharraf agreed to boost their anti-terror work.
"The two presidents agreed to deny sanctuary, training and financing to terrorists and to elements involved in subversive and anti-state activities in each other's country," a joint statement said.
The two sides also pledged co-operation on reducing opium poppy cultivation in Afghanistan and on the repatriation of Afghan refugees from Pakistan.
A joint working group, incorporating Turkey, would be set up to monitor progress on the measures, the statement said. More talks are to be held in Turkey at a later unspecified date.
The meeting was an attempt to ease tension between Pakistan and Afghanistan, whose relationship is crucial to the fight against the Taleban and other militants in the region.
The BBC's M Ilyas Khan in Karachi says there has been an atmosphere of recrimination between the neighbours since 2004, when Taleban raids from sanctuaries in Pakistan's tribal belt started gathering momentum.
Both countries accuse each other of not doing enough to fight the Taleban.
Afghanistan says Taleban fighters are using Pakistan's tribal areas as a base for attacks on Afghanistan and accuses Islamabad of supporting them.
Mr Karzai has accused Pakistani intelligence agencies of harbouring top Taleban leaders and last year went as far as accusing Pakistan of seeking to enslave Afghanistan.
But Pakistan's president points to thousands of troops he has sent to patrol the region, and in turn accuses Mr Karzai of failing to act against the insurgents.
Gen Musharraf says Kabul and Western troops should also share responsibility for plugging the border.
Pakistan's proposal to fence and mine sections of the border has caused particular anger on the Afghan side, and last week the two countries' troops clashed over it.
Our correspondent says Monday's meeting should be viewed, at best, as the start of a confidence-building exercise.
But he says that may depend on the extent to which the Pakistani establishment is willing to change its national security agenda on the border.