Ambulances are still operating, and number of casualties may rise, an official said.

Taliban suicide bombers killed 48 people in two separate attacks in Afghanistan on Tuesday, the deadliest taking place near an election rally by President Ashraf Ghani, though he was unhurt.

The attacks happened 11 days before Afghanistan's presidential election, which Taliban commanders have vowed to violently disrupt, and follow collapsed peace talks between the United States and the insurgent group.

Ghani, who is seeking a second five-year term in voting on Sept. 28, was due to address a rally in Charikar, the capital of central Parwan province, when a suicide bomber attacked the gathering.

The blast killed 26 people and wounded 42, said Nasrat Rahimi, spokesman for the interior ministry.

"When the people were entering the police camp, an old man riding a motorcycle arrived on the highway and detonated his explosives, causing casualties," said Parwan province's police chief Mohammad Mahfooz Walizada.

In the wake of the attack, bodies littered the dusty ground as smoke rose from the site of the explosion, a giant blue billboard bearing the face of Ghani's running mate Amrullah Saleh looming over the scene.

With sirens wailing, rescuers rushed to lift the wounded into the backs of pick-up trucks for evacuation.

"Women and children are among them and most of the victims seem to be the civilians," said Abdul Qasim Sangin, head of Parwan's provincial hospital.

The president was nearby but unharmed, and later took to Twitter to condemn the bombing at the rally.

"Taliban tried to break this unity by targeting innocent civilians," he wrote. "They shamelessly accepted responsibility at a time when they're cloaking acts of terror as efforts for peace."

"PEOPLE WERE GIVEN WARNING"

In a separate incident, a man on foot blew himself up in the centre of the capital Kabul, sending ambulances and Afghan forces rushing to the blast site.

"I was waiting at the entrance of the recruitment centre," said Mustafa Ghiasi, lying on a hospital bed after being wounded in the explosion. "I was behind two men in line when suddenly the blast struck."

Twenty-two people were killed, and 38 were wounded, said Rahimi, the interior ministry spokesman. Most of the dead were civilians, including women and children, though six were security force members.

The Taliban said it carried out the two attacks, and a statement issued by a spokesman for the insurgents said they were aimed at security forces.

"People were given warning," the statement said.

"Do not take part in the puppet administration's election rallies, because all such gatherings are our military target," said the statement. "If, despite the warning, someone get hurt, they themselves are to blame."

Addressing the Kabul attack, Afghanistan's president lashed out at the Taliban as the "coward enemy" for targeting civilians.

"I offer my heartfelt condolences to victims of today's tragedies in Kabul and Parwan and pray for speedy recovery of those who were wounded," Ghani wrote on his official Twitter account. "We stand united in this hour of grief."

Pakistan, which denies accusations that it shelters the Taliban, also condemned the attack.

"We offer our heartfelt condolences to the bereaved families," it said in a statement.

Security at rallies across the country has been tight following threats by the Taliban to attack meetings and polling stations. The group has vowed to intensify clashes with Afghan and foreign forces to dissuade people from voting in the upcoming elections.

Last week, peace talks between the United States and the Taliban collapsed. 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 negotiations, 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.