Casualties were expected to rise as rescuers cleared the rubble. (File photo)

A Taliban truck bomb killed at least 20 people and wounded 95 when it exploded near a hospital in southern Afghanistan on Thursday, a provincial official said.

Casualties were expected to rise as rescuers cleared the rubble.

The Taliban, who have been carrying out nearly daily attacks since the collapse of peace talks with the United States this month, said the target was a nearby building of the government's intelligence department in Qalat, the capital of Zabul province.

"The bomb was huge and it was carried by a mini-truck," said a senior defence ministry official in the capital, Kabul, speaking on condition of anonymity.

The militants wanted to target a training base for Afghanistan's powerful National Directorate of Security, but parked the vehicle laden with explosives outside a hospital gate nearby, another defence ministry source said.

After the blast, a security officer stood holding a swaddled baby, its parents absent and buildings collapsed into piles of rubble behind him.

"I was searching for the injured, many people were evacuated, and I saw this child," the unnamed officer said in a video circulating on social media. "I asked other police, 'Who is this?' They said the mother was injured and the child was left here. The father may be outside somewhere - we are going to find him now."

The Taliban said a statement said the target of their attack was a national intelligence service office.

"It is completely destroyed and tens of security personal were killed," Taliban spokesman Zabihullah Mujahid said in the statement. "The hospital also took damage, the reason being that the enemy has taken positions in civilian areas and they are using them as shields. We were not aiming for the hospital."

Twenty bodies and 95 wounded people had been evacuated from the blast site, said Haji Atta Jan Haqbayan, a member of the provincial council in Qalat.

"The number of casualties may rise as rescue teams and people are still searching for bodies under the rubble," he added.

Several women, children, health workers and patients in the hospital were critically injured in the blast.

There has been no let-up in Taliban attacks across Afghanistan as it prepares for a presidential election this month.

The Taliban has said that its fighters will step up their campaign against the Afghan government and foreign forces to dissuade people from voting in the Sept. 28 election.

More than 9 million Afghans are expected to vote in the presidential election, during which the government has committed more than 70,000 security personnel across Afghanistan to protection duties.

U.S. President Donald Trump abruptly ended talks this month with the Taliban for a deal on the withdrawal of thousands of American troops from Afghanistan in exchange for security guarantees from the hardline Islamist group.

The talks, which did not include the Afghan government, were intended to lead to wider peace negotiations to end the 18-year-long war in Afghanistan.