U.S. President Donald Trump said he spoke Tuesday with the leader of the Taliban, days after Washington and the extremist group signed an agreement that calls for the withdrawal of American troops from Afghanistan after more than 18 years.

Trump is believed to be the first U.S. president to speak directly to the Taliban, though he suggested it wasn't his first time. Asked if Tuesday was his first conversation with a leader of the Taliban, Trump said: "I don't want to say that."

"The relationship is very good that I have with the mullah," Trump said, presumably referring to Taliban leader Mullah Abdul Ghani Baradar. "We had a good long conversation today and, you know, they want to cease the violence. They'd like to cease violence also."

"They're looking to get this ended and we're looking to get it ended," he told reporters. "I think we all have a very common interest."

The call came as officials in Afghanistan said five Afghan police officers died in a Taliban attack on a security checkpoint near a copper mine on Tuesday, a day after the insurgents decided to resume operations against local forces.

A Taliban spokesperson did not confirm or deny responsibility for the attack in eastern Afghanistan when contacted by Reuters, saying he was collecting information.

The militants had a reduction of violence arrangement in place before the signing of a troop withdrawal agreement with the United States in Doha on Saturday.

But on Monday they decided to end that for Afghan forces, while still holding back on fighting American and other foreign troops, according to sources.

Tuesday's "heavy clash" killing the Afghan officers took place at a checkpoint at the Mes Aynak copper mine in Logar province, said Deedar Lawang, a spokesperson for Logar's provincial governor.

Hasib Stanekzai, head of Logar provincial council, told Reuters the police officers were soft targets during the early morning attack as they had no heavy weapons.

A senior U.S. official said the attack was being investigated.

A spokesperson for Afghanistan's interior ministry said that in 24 hours, the Taliban carried out 33 attacks against Afghan forces in 16 provinces, killing six civilians. She did not say how many Afghan security force members had died.

"Taliban should give up killing civilians, otherwise [Afghan National Security forces] take action and eliminate them in the defence of our people," said the spokesperson, Marwa Amini.

Deal at risk

U.S.-led forces ousted the Taliban from power in 2001.

But the nation has been in stalemate since, with Taliban forces controlling some territory but unable to capture major urban centres.

The weekend agreement envisages a full withdrawal of all U.S. and coalition forces within 14 months, dependent on security guarantees by the Taliban.

"If the announcement of resumption of violence by Taliban is verified, this is against the spirit of the agreement just signed in Doha," tweeted the European Union's special envoy for Afghanistan, Roland Kobia.

The deal also could unravel if the Taliban and other factions of Afghan society fail to have successful talks about a political way ahead for the country.

Those talks are scheduled to begin next Tuesday.

Trump said it's still unclear what the Afghans will do when they sit with the Taliban and attempt to draft a peaceful political future for the nation. He added: "The country really has to get it ended. We've been there for 20 years. Other presidents have tried and they were unsuccessful."

A short time before Trump spoke, Taliban spokesman Zabiullah Mujahid tweeted that the president had spoken on the phone with Baradar.

The Afghan Taliban also released a statement, saying the phone call took place shortly after 9:30 a.m. ET and lasted for 35 minutes. SITE Intelligence Group, which monitors communications from militant organizations, said the Taliban statement claimed the call was held in the presence of a number of members of the Taliban negotiating committee and Zalmay Khalilzad, the U.S. envoy who negotiated the deal.

According to the statement, the conversation was about how both sides will put the agreement in place and that the mullah assured Trump that if the United States honoured the agreement, then the U.S. and the Taliban will have "positive bilateral relations."

The statement said that Taliban leader told Trump: "Mr. President! Take determined actions in regards to the withdrawal of foreign forces from Afghanistan and do not allow anyone to take actions that violate the terms of the agreement thus embroiling you even further in this prolonged war."