(CNN) President Donald Trump said Saturday that Taliban leaders were to travel to the US for secret peace talks this weekend but that the meeting has been canceled and he's called off peace talks with the militant group entirely.

Trump tweeted that he scrapped the meeting after the Taliban took credit for an attack in Kabul, Afghanistan, that killed a dozen people, including an American soldier

Inviting Taliban leaders onto American soil is an unprecedented move and a significant development in America's longest running war just days from the anniversary of the September 11, 2001, terrorist attacks. It comes after Trump said as recently as late last month that he is planning to withdraw thousands of US forces from Afghanistan but will keep 8,600 troops in the country at least for the time being. It's not clear if Trump's Saturday night announcement will impact that plan.

"Unbeknownst to almost everyone, the major Taliban leaders and, separately, the President of Afghanistan, were going to secretly meet with me at Camp David on Sunday," Trump tweeted Saturday night.

Trump claimed that before traveling to the US on Saturday evening, "Unfortunately, in order to build false leverage, they admitted to......an attack in Kabul that killed one of our great great soldiers, and 11 other people."

"I immediately cancelled the meeting and called off peace negotiations," Trump added.

CNN military analyst John Kirby, a retired Navy rear admiral and former State Department and Pentagon spokesman, called the news "stunning," saying this would give the Taliban "a boost of political legitimacy that they don't deserve at this stage in negotiations and would be a huge propaganda victory for them, not to mention a slap at the Afghan government and President Ghani."

The President slammed the leaders for thinking that the attacks would improve their negotiating position.

"What kind of people would kill so many in order to seemingly strengthen their bargaining position?" he tweeted . "They didn't, they ... only made it worse!"

The State Department referred CNN to the White House for comment. The US National Security Council did not respond to request for comment.

The Afghanistan government blamed the Taliban for the canceled peace talks, saying the group's "obstinacy to increase violence against Afghans" is the "main obstacle" to peace negotiations.

"We have consistently stressed that genuine peace is possible when the Taliban stop the killing of Afghans, embrace an inclusive ceasefire, and enter into direct negotiations with the Afghan government," the government said in a statement.

Responding on Sunday to Trump's decision to cancel the peace talks, the Taliban said the move "would not harm anyone else but the Americans themselves" and will show the US' "anti-peace stance in (a) more clear way."

However, the Taliban left the door open to future talks, saying, "By continuing the dialogue, the Islamic Emirate has proved to the world that others have imposed war on us, and if the path of dialogue is open we are committed to it."

Taliban continues campaign of violence

The insurgent group has not halted its campaign of violence as the peace talks with the US have taken place but Thursday's killing of an American when a deal was reportedly close appears to have prompted the dramatic move from the President.

The Pentagon announced Friday that Sgt. 1st Class Elis Angel Barreto Ortiz was killed in Afghanistan. Barreto, a 34-year-old paratrooper from Morovis, Puerto Rico, died when a car bomb exploded at a checkpoint near NATO headquarters and the US embassy in Kabul. Barreto is the 16th US service member to be killed in Afghanistan in 2019, and three other American service members have been killed in recent weeks.

The Afghan government did not push for the cancellation of the meeting at Camp David after the Taliban attack this week, it was a decision by the White House and the State Department, according to a source familiar with the planning.

Despite Trump saying in his tweet Saturday that peace negotiations are called off, new dates are being discussed by the White House for a potential meeting with the Taliban and the Afghan government, the source says. It's unclear if the Taliban will have to make hard and fast commitments before the meeting or if Trump is using the cancellation and rescheduling simply as a negotiating tactic.

The US troop withdrawals could mark the beginning of the conflict triggered by 9/11 that has cost billions in taxpayer dollars and claimed more than 2,300 American lives.

In his tweets, Trump cast doubt on the leaders' bargaining abilities in light of the killings.

"If they cannot agree to a ceasefire during these very important peace talks, and would even kill 12 innocent people, then they probably don't have the power to negotiate a meaningful agreement anyway," he added . "How many more decades are they willing to fight?"

Secret meeting in the works

Earlier this week CNN was told by a source informed on the matter that the State Department and the National Security Council were working on scheduling a US-Afghan government meeting as well as a US-Taliban meeting on US soil, though the location was never explicitly stated. Afghanistan wanted it sooner rather than later, but the US side was looking at the middle of this month as the most likely date.

Trump was involved in the planning personally, hoping that it would come to fruition in the coming week, the source said. He got personally attached to the outcome and the logistics of the talks after meeting with top advisers about the Afghan peace process in August.

Before that, US Special Envoy for Afghanistan Zalmay Khalilzad had been given a long leash to do the negotiating to bring all parties -- including the Taliban -- to an agreement.

A source familiar with details of the meeting told CNN the plan had been for Trump to meet separately with Afghan President Ashraf Ghani and with the Taliban's chief negotiator, Mullah Abdul Ghani Baradar. If Trump's meetings had gone well, the hope was to convince the two Afghans to meet face to face.

The stakes were high, according to the source, because it would have been politically toxic for Mullah Baradar to meet with Ghani. The Taliban negotiator is not authorized to talk to the Afghan government.

The Afghan government had for months been frustrated that they had not been invited to Washington by Trump during his first two and a half years in office. Afghan officials had planned to come last year right after UN General Assembly meeting but the trip fell apart because the timing did not work out, and the Trump administration canceled the visit.

Trump's announcement Saturday comes as the US and the Taliban appeared to be close to finalizing a peace deal. Khalilzad returned to Doha, Qatar, this week to resume talks with the Taliban.

Khalilzad had told Afghanistan's TOLOnews on Monday that the US and the Taliban have reached an agreement "in principle," pending final approval by Trump.

Khalilzad said that based on the draft agreement, the US would pull troops from five bases across Afghanistan within 135 days so long as the Taliban met conditions set out in the agreement. The US currently has about 14,000 service members in Afghanistan, alongside NATO troops, helping to train and advise Afghan troops and conducting counterterrorism operations.

This story has been updated with additional developments Saturday.