KABUL, Afghanistan — The Taliban infiltrated an Afghan intelligence base on Monday, killing dozens of people in what Afghan officials said was one of the deadliest attacks against the intelligence service in the 17-year war with the Taliban.

While the Afghan police and army have been dying in record numbers, the loss of intelligence forces, who are often better trained and equipped, was another indication of the violence stretching the Afghan government’s defenses, even as the United States may be preparing to withdraw some of its troops.

The attack, early Monday morning, came hours before the Taliban announced they had resumed peace talks with American officials. It was a sign, analysts said, of how violence is likely to grow deadlier even as the sides of the long war have indicated a willingness to seek a negotiated settlement.

Akhtar Mohammad Khan Tahiri, the head of the provincial council in Wardak Province, where the base is, said the target was a training center for pro-government militia members run by the National Directorate of Security, Afghanistan’s intelligence agency.