In Washington for a visit with his US counterpart, Lloyd Austin, Wallace said the lessons of the past 20 years “will not have been lost on the Taliban”, and acknowledged that the UK would likely have to work with the group.

Last week, the Taliban claimed to control 85% of the country’s territory. However, the Afghan leadership has dismissed this assertion as part of a propaganda campaign.

“Whatever the government of the day is, provided it adheres to certain international norms, the UK government will engage with it,” Wallace told The Telegraph. He warned that the “relationship” would be reviewed “if they behave in a way that is seriously against human rights”.

Last week, UK Prime Minister Boris Johnson promised that Britain would remain committed to Afghanistan despite the end of its military campaign in the country.

While recognising that the prospect of the UK working with the Taliban would be controversial, given the deaths of 457 British military personnel during the conflict, Wallace said “all peace processes require you to come to terms with the enemy”.

Claiming that the Taliban “desperately want” international recognition, Wallace said they cannot “unlock financing and support [for] nation-building” with a “terrorist balaclava on”.

“You have to be a partner for peace, otherwise you risk isolation. Isolation led them to where they were last time,” he said, adding, “The poverty of their own people is an important issue to be dealt with, and you cannot deal with that on your own in isolation.”

Wallace also called on both the Taliban and Afghan President Ashraf Ghani to “show leadership” and work together to bring stability to the country after two decades of conflict.

Senior Afghan leadership representatives are scheduled to fly to Doha this week for talks with the Taliban, which has reclaimed several key areas in the country as the departure of American forces continues. The US withdrawal is expected to conclude on August 31.

“But in the end, if there is a government, and it is a government of both [existing groups and the Taliban], and we have committed to a diplomatic relationship, then that’s exactly what it will be,” Wallace said.