HR McMaster was on his first South Asian trip since the new US administration took office in January, earlier stopping in Afghanistan, Pakistan's war-ravaged neighbour to the west.
Official statements on Monday gave little indication of whether the Trump administration would adopt a new, tougher policy on Pakistan.
Afghan officials have long accused Pakistan of providing Taliban terrorists shelter, and perhaps support, on its side of the countries' porous border. Pakistan denies it shelters the Afghan Taliban and says it fights against all the region's terrorist groups with equal vigour.
Mr McMaster, a US Army general who served in the American-led international force in Afghanistan, indicated frustration with Pakistan in an interview with an Afghan news channel on Sunday.
"As all of us have hoped for many, many years, we have hoped that Pakistani leaders will understand that it is in their interest to go after these groups less selectively than they have in the past," he told TOLO News in Kabul.
In Pakistan, Mr McMaster's gave no interviews and the official statement on his visit was more diplomatically couched.
"General McMaster expressed appreciation for Pakistan's democratic and economic development, and stressed the need to confront terrorism in all its forms," the US Embassy said in a statement.
Mr McMaster met Pakistan Prime Minister Sharif and Chief of Army Staff General Qamar Javed Bajwa as well as top foreign policy and national security officials.
"The prime minister conveyed Pakistan's readiness to work with the international community to explore ways in which the Afghan crisis can be resolved," Mr Sharif's office said in a statement.
Follow NDTV for latest election news and live coverage of assembly elections 2019 in Maharashtra and Haryana.
Subscribe to our YouTube channel, like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.