(CNN) US Secretary of Defense James Mattis made an unexpected trip to Afghanistan Friday, his visit coming as the US tries to make headway in the country after 17 years of war.

Mattis met with Army Gen. Scott Miller, the new Commander of Resolute Support and US Forces-Afghanistan, who assumed the role last week.

The US Defense Secretary also met with Afghan President Ashraf Ghani. That meeting was attended by officials from both countries, including Chairman of the Joint Chiefs of Staff Gen. Joseph Dunford, Miller, along with the Afghan minister of defense and national security adviser.

At the outset of the meeting, Ghani thanked the American officials for the sacrifice of US service members and their families and praised the Trump administration's South Asia strategy, particularly its decision to boost air support and intelligence surveillance and reconnaissance flights in Afghanistan.

Mattis touched down in the country amid a bloody start to September.

Read More