He defined victory in Afghanistan as a political settlement between the Taliban and the government, and an Afghan military that is capable of securing the country largely on its own.
Mattis planned to meet with Gen. John Nicholson, the top American commander in Afghanistan, as well as Afghan President Ashraf Ghani.
U.S. Defense Secretary Jim Mattis has arrived in Kabul for an unannounced visit to take stock of the war and the prospects of drawing some elements of the Taliban into peace talks with the Afghan government.
United States defence secretary Jim Mattis believes victory in Afghanistan is still possible, though not necessarily on the battlefield but in facilitating a Taliban reconciliation with the country's government.
The UN said on Tuesday that 30,672 people have been displaced in Afghanistan since the beginning of the year due to continued conflict.
United Nations said that over 445,000 people were displaced due to conflict in the country in 2017.
The March 13 visit, which was not announced in advance due to security concerns, comes as the United States is putting new resources into the more than 16-year-old war. "It's all working to achieve a political reconciliation, not a military victory", Mattis said.
PMB's Visit To Benue Sign Of Hope - Ortom
He denied insinuations that he overlooked the killings that happened in Benue, saying he is genuinely anxious over them. President Buhari was surprised that Idris breached his order.
While the United States has been stepping up battlefield pressure, Afghanistan's worldwide partners have sought to build diplomatic support from neighbouring countries to push the militants to the negotiating table.
Ghani, during a meeting with Mattis, described the new US strategy as a game changer, allowing Kabul to extend its peace offer to the Taliban without doing so from a position of weakness.
"We've had some groups of Taliban - small groups - who have either started to come over or expressed an interest in talking".
Mattis said the jump in attacks on civilians was an indication that a pressured Taliban is unable to conduct broader, ground-taking operations.
The visit is Mr Mattis's second since President Donald Trump announced last August that, despite his instinct to pull United States troops out of Afghanistan, his administration would take a more aggressive approach to the conflict, now in its 17th year.
However, the Taliban appears likely to miss that conference and have ruled out direct talks with the Western-backed government in Kabul, which they say is an illegitimate, foreign-imposed regime.
Mattis also said he had seen some changes in Pakistan's behavior since Trump blasted the country a year ago for harboring the Taliban.