Mattis is the first member of the US president’s cabinet to visit Afghanistan since the strategy announcement to keep American boots on the ground there indefinitely.

The unannounced high-level visit comes as Afghan security forces struggle to beat back the Taliban which has been on the offensive since the withdrawal of US-led NATO combat troops at the end of 2014.

The resurgent militants have promised to turn Afghanistan into a “graveyard” for foreign forces and have been mounting deadly attacks as they maintain control over large swathes of the country.

US generals have for months been calling the situation in Afghanistan a “stalemate”, despite years of support for Afghan partners, continued help from a NATO coalition and an overall cost in fighting and reconstruction to the United States of more than $1 trillion.

The Afghan war turns 16 next month, and is America’s longest-ever conflict.

Under Trump’s plan, the US is sending more than 3,000 additional troops to Afghanistan, on top of the 11,000 already on the ground, to train and advise the country’s security forces.