At least 45 people were killed and as many as 70 were wounded by a suicide bomber who drove an armored Humvee packed with explosives at the base in eastern Maidan Wardak province on Monday, the officials said.
There were fears the death toll from the daytime assault could increase. The base, which also serves as a training center for pro-government militias, is run by Afghanistan's intelligence service known as the National Directorate for Security, or NDS.
The NDS said its reports show 36 military personnel were killed and 58 were wounded. Though the agency's figures were lower than what provincial officials had reported, it was still an unprecedented casualty toll for the agency, among the best equipped and trained in Afghanistan.
The agency said the suicide bomber had managed to penetrate the gate of the base on the outskirts of Maidan Shar, the provincial capital located about 40 kilometers (25 miles) from Kabul, even though guards fired at the vehicle.
Khawanin Sultani, a council member in the province, said a main building collapsed from the explosion, which likely contributed to the high casualty toll.
"Most of the bodies were under the destroyed building," he said.
The Taliban claimed responsibility in a statement to the media just hours after the attack and later said its representatives met Monday with U.S. representatives to discuss "ending the invasion of Afghanistan" in talks that were to continue Tuesday. They are meeting in Qatar, where the Taliban have a political office.
The timing of the attack, one of the worst Taliban assaults on Afghan forces in recent years, and the Qatar meeting that was meant to pave way for talks aimed at resolving Afghanistan's 17-year war, underscored the audacity of the insurgents in the face of stepped-up peace efforts.
The Taliban now hold sway in almost half of Afghanistan and carry out attacks on a daily basis, mainly targeting the country's beleaguered security forces.
After the suicide bomber struck, four other attackers engaged in a shootout with Afghan troops, according to Sultani, the provincial council member. All the attackers were killed, he said.
About 150 military personnel and others were at the base at the time, he said. The pro-government militia that was hit had been highly effective in securing the province, especially two key highways linking Kabul with the provinces of Kandahar, Maidan Wardak and Bamyan.
"They had participated in so many operations alongside other security forces and had fought against insurgents," Sultani added.
A provincial security official, who spoke on condition of anonymity because he was not authorized to talk to the media, said he counted as many as 75 bodies at the base. There was no official confirmation of this higher toll.
Dozens of ambulances took the wounded to the main provincial hospital or to Kabul, the official said. The blast was so strong that windows of civilian homes outside the base also were shattered, he said.
President Ashraf Ghani's office said the "enemy had carried out a terrorist attack against the intelligence agency's personnel, killed and wounded a number of honest sons of this homeland who were defending their country and protecting their people." An investigation was ordered, the statement added.
There was no official breakdown on how many of the victims were military, intelligence personnel or militia trainees.
The attack was a "tragedy and a big loss to the Afghan security forces," said Mirza Mohammad Yarmand, a former deputy interior minister and a military analyst.
He said it was difficult to believe that the vaunted NSD could have lost such a high number of personnel in a single attack and that there must have been serious negligence on someone's part. He also said there were no other checkpoints along the highway leading up to the base to prevent the attack.
The Taliban statement said they had met with U.S. representatives to discuss "ending the invasion of Afghanistan" in talks that would continue on Tuesday in Qatar.
"Peace talks and negotiations are important and essential for Afghanistan, but not under these unacceptable circumstances," Yarmand said. "If such attacks continue, there must be a cease-fire agreement first."
Last week, the Taliban threatened to walk away from the talks, accusing Washington of seeking to "expand the agenda" — presumably a reference to U.S. demands that the insurgents hold direct talks with the Kabul government.
The Taliban view the Afghan government as a U.S. puppet and have long insisted they will only negotiate directly with Washington.