The post is currently held by Sartaj Aziz, a civilian who is a close ally of Mr Sharif. Mr Aziz also holds the portfolio for foreign affairs.
"The army chief feels that Sartaj Sahib`s attention is divided," a military source said. "So it has been decided that General Janjua will be appointed the national security adviser and Sartaj Aziz can give his full attention to the foreign office."
"This is not about the PM conceding to the Army chief or the Army being a bully, not at all. This is about both sides deciding together."
A military spokesman declined to comment.
Mr Sharif has had rocky relations with Pakistan`s powerful military, who deposed him in a 1999 coup during a previous term as prime minister.
He swept into office again in 2013 vowing to improve relations with India; the two nuclear-armed neighbours have fought three wars since becoming separate nations in 1947.
But many in the military remain deeply suspicious of India, and Mr Sharif has had to reign in his ambitions. Domestic political protests last year forced him to rely more heavily on the military for stability, and India elected Narendra Modi as Prime Minister.
"The Army had advised the PM against engaging PM Modi but he (Mr Sharif) had insisted that he would pursue peace talks," the official said. "He is very disappointed by PM Modi`s response and he has realized that perhaps the advice he got then was correct."
A senior minister in Mr Sharif`s cabinet said the Army Chief had pushed General Janjua`s appointment "for many months," although Nawaz Sharif had preferred to keep his own man, Mr Aziz.
"Now the Army chief has convinced the Prime Minister that the military and the government must ... work together," the minister said.
General Janjua`s appointment follows cooling relations between Pakistan and India after talks between the two were called off in August over a dispute over the agenda. India had said that terror must be discussed, while Pakistan insisted on including Kashmir.
"General Janjua will go to Afghanistan for talks. He will go to the US and yes, when Pakistan-India (national security advisor) level talks resume, it will be General Janjua at the table," the military official said.
Two senior government officials said that General Janjua was respected for his previous posting in Balochistan, a poverty-stricken province with a raging separatist insurgency and widespread reports of human rights abuses by security forces.
Before that, General Janjua was president of the National Defence University, the military`s higher education institute and premier think-tank on national security matters.
He also worked on `Azm-e-Nau,` a military preparedness exercise that had a particular focus on India.
More about: