KABUL — An explosion near an election rally attended by Afghan President Ashraf Ghani killed 26 people — including 4 security forces —and injured 42 others, local officials said, but Ghani was unhurt according to an aide.

Women and children were among the victims in the suicide attack in Parwan province, according to Nasrat Rahimi, spokesman for the Ministry of Interior who said at least 26 people were killed.

Ghani had been due to address the rally in Charikar, capital of Parwan province, north of Kabul, when the suspected militant attack occurred, a health official told Reuters.

"Women and children are among them and most of the victims seem to be the civilians. Ambulances are still operating, and the number of casualties may rise," said Abdul Qasim Sangin, head of the provincial hospital.

A local government official said the attack was carried out by a suicide bomber.

"The president is unharmed," Ghani's aide told Reuters.

In a separate incident, a suicide bomber killed 22 people and injured 38 in the center of Kabul, Rahimi said. Six of the victims were military personnel, he added.

The Taliban claimed responsibility for both attacks. NBC News could not confirm the claim and the Taliban often exaggerates claims in the wake of attacks.

Taliban commanders have vowed to intensify clashes with the Afghan and foreign forces to dissuade people from voting in the Sept. 28 presidential election, when Ghani will bid for a second five-year term.

Security at rallies across the country has been tight following threats by the Taliban to attack meetings and polling stations.

Peace talks between the United States and the Taliban collapsed last week. The two sides had been seeking to reach an accord on the withdrawal of thousands of American troops from Afghanistan in exchange for security guarantees from the insurgents.

The talks, which did not include the Afghan government, were intended as a prelude to wider peace negotiations to end more than more 40 years of war in Afghanistan.