KABUL — A Taliban suicide bomber in a captured U.S. Humvee crashed through the entrance to a provincial training compound of the Afghan intelligence service, followed by several gunmen, in an attack Monday that left scores of trainees and others dead or wounded.

While some officials initially put the death toll as high as 126, Afghanistan’s National Security Directorate announced Tuesday that 36 members of the security forces died in the bombing and shooting assault. The intelligence agency said 58 others were wounded.

At the time of the Monday morning attack, Taliban representatives were meeting with foreign diplomats in Qatar, part of a U.S.-initiated push to start peace talks and reach a settlement to the 17-year insurgent conflict. Even as a Taliban spokesman claimed its forces had killed 190 in the Wardak province attack, he said in an email to journalists that talks in Qatar would continue Tuesday.

Although the simultaneous massacre and olive branch might seem contradictory, Afghan and foreign experts said they are more likely part of a deliberate dual strategy. It is believed to be aimed in part at increasing insurgent leverage in peace talks and at keeping morale high among hard-line Islamist fighters while unarmed Taliban emissaries converse with the enemy.

In the email Monday, the Taliban spokesman said the ongoing talks would focus on “ending American occupation with assurance that no one will be harmed in Afghanistan.” Although the group’s battlefield targets are mostly Afghan security forces, its diplomatic target is mainly the United States because the Taliban regards the Kabul government as a U.S. puppet. 

The Wardak attack followed high-profile, aggressive actions by the insurgents as the talks continued. On Sunday, a Taliban suicide bomber rammed an official convoy in Logar province, which borders greater Kabul. The provincial governor survived, but the blast killed eight of his bodyguards, police officials said.

Outside a compound for foreigners in Kabul on Jan. 14, a powerful truck bombing, claimed by the Taliban, killed at least four people, including one American civilian, and wounded more than 100.

Monday’s insurgent assault, which destroyed the security compound, was especially deadly and humiliating. Exact casualty figures could not be immediately determined, with officials in Wardak and Kabul giving wildly varying estimates, in part because officials of the Afghan spy agency, which prides itself on high-level skills and sophistication, refused to release any information for nearly 24 hours. 

 But with even conservative accounts initially putting the death toll between 30 and 50, it was by far the deadliest attack at any national intelligence target. If the final toll passes 100, it would rank among the highest at any Afghan security compound.

The record toll was in April 2017, when a Taliban attack at a military base in Balkh province killed 140. The intelligence agency headquarters in Kabul has been attacked several times, and one 2013 bombing at its gate killed at least 30 people, mostly civilians.

Sharif Hotak, a member of the Wardak provincial council, said that he saw the bodies of 35 Afghan forces in a hospital and that “many more were killed.” He said the government was “hiding the accurate casualty figures to prevent a further dip in morale of the Afghan forces.”

 But the dual strategy of talking and fighting has also accelerated on the other side.

 After months of discouraging reports that the Taliban controls record amounts of territory and is killing record numbers of Afghan civilians and troops, the national defense forces, supported by U.S. advisers and air combat missions, have achieved notable successes. Over the past weekend, Afghan security officials said more than 60 Taliban members were killed in bombing raids on insurgent hideouts in half a dozen provinces.

Afghan officials said recent changes in President Ashraf Ghani’s security team were aimed at sending a strong message to the Taliban that the government is equally ready to negotiate or keep fighting. Ghani said last year that 28,000 Afghan police officers and soldiers have been killed since 2015. On Sunday, in a speech formally launching his reelection campaign, Ghani said his government was determined to bring peace, but “we will not beg for it.”

A U.S. military official here, speaking on the condition of anonymity because he was not authorized to speak publicly, also said this week that “Afghan and foreign forces are killing record numbers of Taliban.”

Although President Trump has said he may withdraw half of the 14,000 U.S. troops stationed in Afghanistan, U.S. military officials here have recently described intensifying their combat involvement in an effort to force the Taliban to reach a settlement. 

Sayed Salahuddin contributed to this report.