Afghan President Hamid Karzai and his Pakistani counterpart Pervez Musharraf have discussed boosting cross-border security during talks in Islamabad.
Top of the agenda was cross-border security
Gen Musharraf said greater co-operation would help combat terrorism, Pakistan's state-run APP news agency reported.
It said both men agreed that "extremism and terrorism" must be addressed.
Kabul wants Islamabad to crack down on Taleban rebels who launch attacks in Afghanistan. Pakistan denies claims it is lax on militants in border areas.
Meanwhile, authorities in the western Afghan province of Farah say the partially decapitated bodies of two intelligence agents have been recovered and handed over to their families.
The men were abducted by unknown assailants on Monday. The provincial governor said the men had been engaged in gathering intelligence on the Taleban and other militants.
Afghanistan and Pakistan share a 1,400-mile (2,250km) border which is largely mountainous and extremely difficult to patrol.
Taleban and al-Qaeda elements are believed to be operating on both sides of the border.
More than 500 Afghans were freed as a goodwill gesture
The Taleban have been blamed for an increase in violence in recent months, including a spate of suicide bombings inside Afghanistan.
Before the meeting Mr Karzai's spokesman, Khaleeq Ahmed, said the president would be urging Pakistan to show the same commitment to defeating Taleban rebels as it did in combating al-Qaeda.
Back in Kabul, Afghan Interior Ministry spokesman Yousuf Stanezai told the Associated Press the security forces had arrested "a large number" of Pakistanis who were linked to a series of recent suicide bombings.
He said many of those detained had admitted being trained at bases on the Pakistani side of the border.
"The terrorists who come here for suicide attacks are attending training bases in Pakistan and are getting all their equipment there," said Mr Stanezai.
Ahead of the two-day visit, Pakistan freed 562 Afghans as a gesture of goodwill. They had been arrested in Karachi during a crackdown on illegal immigration.
Pakistan supported the Taleban but changed its policy after the 11 September 2001 attacks on the US and the subsequent US-led invasion of Afghanistan which removed the hard-liners from power.
Hundreds of Taleban and al-Qaeda militants were believed to have fled to Pakistan after they were toppled.
There have been a number of anti-Pakistan demonstrations in Afghanistan in recent weeks.