Afghan National Security Adviser Rangin Dadfar Spanta held talks with his counterpart Sartaj Aziz during a one-day official visit.
In a joint statement, the two sides said that the main focus of meeting was on strengthening bilateral security cooperation and the two countries agreed to take action against all terrorists without making any distinction among them and their hideouts on their respective sides.
"The two sides agreed that terrorism was a common enemy and emphasised closer cooperation and coordination at institutional level to deal with this common menace," the statement said.
Pakistan reaffirmed providing all-out support to an Afghan-led and Afghan-owned peace process.
It was agreed to further strengthen bilateral engagement at all levels for addressing each other's concerns and pursuing peace and stability in the region.
The visit came after weekend allegations by Afghan defence minister Bismallah Mohammadi that Pakistan was sending troops in plainclothes to attack Afghan security forces across the border in Kunar.
Spanta also called on Pakistan Prime Minister Nawaz Sharif and delivered Afghan President Hamid Karzai's letter.
The senior Afghan official also met Pakistan's army chief General Raheel Sharif.
Spanta was accompanied senior officials from the Ministries of Foreign Affairs and Defence, National Directorate of Security and Afghan National Security Council.
"Pakistan is committed to building a close, cooperative relationship with Afghanistan, based on mutual understanding and trust. The visit would help advance Prime Minister Nawaz Sharif's vision of peace and development in the region," Pakistan's Foreign Office said.
Pakistan has asked Afghanistan to cooperate in stopping Pakistani Taliban militants fleeing the current military operation in North Waziristan.
