WASHINGTON—President Trump said Saturday he called off a planned Camp David summit with Taliban leaders and Afghan President Ashraf Ghani after a Taliban bomb attack in Kabul killed an American soldier.

On Twitter, Mr. Trump said the Afghan government and Taliban officials had been coming to the U.S. Saturday night. The president’s tweets reflected his most extensive direct involvement in the monthslong talks.

“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,” he wrote. Following the attack, “I immediately cancelled the meeting and called off peace negotiations. What kind of people would kill so many in order to seemingly strengthen their bargaining position?”

The cancellation of the meeting is major setback in efforts to reach a comprehensive settlement of the nearly 18-year Afghan war, America’s longest. It couldn’t be determined whether the U.S.-Taliban negotiations in the Gulf state of Qatar had been suspended.

The U.S. and the Taliban resumed direct talks in Qatar’s capital Doha more than a year ago and last weekend, Zalmay Khalilzad, the chief negotiator to the Afghan peace process, said U.S. and Taliban negotiators had reached the “threshold” of agreement on a troop drawdown following nine rounds of talks in Qatar. The accord awaited only President Trump’s signoff, he said. The announcement followed assaults by the Taliban on two northern Afghan cities.