The decision was taken after a marathon meeting which continued for about 11 hours.
The meeting, chaired by Prime Minister Nawaz Sharif, was called to formulate a plan to deal with militancy after the Taliban attack on an army school in Peshawar in which 150 people, mostly children were killed.
A government official said that the leaders agreed to set up special military courts for two years with a clear mandate to try the cases of militants.
The parties were earlier divided over the setting up of the special military courts.
Also Read
Those who earlier opposed the idea were fewer in number but included influential parties like Right wing Jamaat-i-Islami, secular Mutahida Qaumi Movement and Awami National Party (ANP).
Opposition Pakistan People's Party of former president Asif Ali Zardari had also sought time for consultations.
After the marathon meeting, the PPP agreed on the setting up of military tribunals. Its leader Khursheed Shah told media that constitution would be amended to create military courts for limited period.
Sharif Government wanted to set up military courts for speedy trial as traditional justice system is corrupt and slow and has failed to deliver.