Iran has criticized US talks with the Taliban on ending the Afghanistan war, saying Washington was elevating the role of the militants.

Foreign Minister Mohammad Javad Zarif acknowledged that Iran had also opened a dialogue with the Taliban but said that the US push for a deal with the extremists was “seriously wrong”.

“An attempt to exclude everybody and just talk to the Taliban has alienated the government, has alienated the region, has alienated everybody else and it achieved nothing, as you’ve seen from the statement that came from the Taliban,” Zarif said, apparently referring to the militants’ announcement of a new spring offensive.

“I was the first to say that in any peace in Afghanistan, the Taliban cannot be set aside or isolated,” Zarif said at the Asia Society in New York, which he was visiting to take part in a UN session.

“But you cannot negotiate the future of Afghanistan with the Taliban. The Taliban only represent a segment of Afghan society, not all of it,” he said.

President Donald Trump has voiced impatience at ending the longest-ever US war, launched after the September 11, 2001 attacks on the United States.

US envoy Zalmay Khalilzad is set shortly to hold a fresh round of talks in Qatar with the Taliban, with early indications saying Washington will agree to pull troops and that the militants will promise not to allow foreign extremists on their soil.

But the Taliban have refused to negotiate with President Ashraf Ghani’s internationally recognized government, with a would-be breakthrough meeting recently collapsing in a dispute over the delegation list.

Despite its tense relations with the United States, Iran had quietly backed the initial US invasion that ousted the Taliban, Sunni Muslims who imposed an austere interpretation of Islam over Afghanistan from 1996 to 2001.

Iran, led by Shiite clerics, nearly went to war with the Taliban in 1998 after an attack on its consulate in the Afghan city of Mazar-i-Sharif killed nine Iranian diplomats and a journalist.

But Iran has more recently sought to build relations with the Taliban, mindful of preserving interests in the neighbouring country.