Former Afghan president Hamid Karzai had long accused Islamabad of tacit support of the Afghan Taliban, whose leaders are believed to be hiding in Pakistan.
"Any effort by any militant or group to destablise Afghanistan will be dealt with severely and such elements will be outlawed and hunted down," Mr Sharif said.
"Coordinated operations will be planned and conducted on a mutually agreed basis to target militant hideouts along the border."
He was speaking during a joint appearance with Afghan President Ashraf Ghani, who has made improving relations with Pakistan a priority since taking office last year.
The neighbours are seeking to increase military cooperation to fight the two main branches of the Taliban, one fighting to topple the US-backed government in Kabul and the other against Pakistan's government.
Mr Ghani's move to mend ties with Pakistan is partially aimed at convincing Islamabad to use whatever influence it has among Taliban leaders to persuade them to join peace talks.
The Afghan Taliban have been fighting to restore their hard-line Islamist regime that was ousted in a US-led military action in retaliation for sheltering the al Qaeda planners of the September 11, 2001 attacks on American cities.
Afghan and Taliban representatives recently met in Qatar for informal discussions on a possible peace process, but the insurgents have also launched attacks across the country as part of their annual spring offensive.
The Taliban push has brought its fighters to the outskirts of a major northern city, Kunduz, and battles with Afghan army and police are ongoing.