A five-year-old boy trapped for three days down a remote Afghan village well died minutes after being pulled out on Friday, following a rescue effort the country's new Taliban rulers said showed they would spare nothing for their citizens.

The child, named Haidar, on Tuesday slipped and fell to the bottom of a well being dug in Shokak, a parched village in Zabul province, about 400 kilometres (250 miles) southwest of the capital Kabul.

"With great sorrow, young Haidar is separated from us forever," said Taliban interior ministry senior adviser Anas Haqqani, in a tweet echoed by several of his colleagues.

Officials said the boy slipped to the bottom of the 25-metre (80-foot) shaft, but was pulled by rope to about 10-metres before becoming stuck
Officials said the boy slipped to the bottom of the 25-metre (80-foot) shaft, but was pulled by rope to about 10-metres before becoming stuck AFP / Javed TANVEER

"This is another day of mourning and grief for our country."

Haidar was buried later in the day, his small grave covered by a mound of gravel and marked by a ribbon of white cloth.

Zabul police spokesman Zabiullah Jawhar told AFP Haidar was clinging to life when rescuers reached him.

"In the first minutes after the rescue operation was completed, he was breathing, and the medical team gave him oxygen," he said.

Engineers used bulldozers to try to reach the point where Haidar was trapped
Engineers used bulldozers to try to reach the point where Haidar was trapped AFP / Javed TANVEER

"When the medical team tried to carry him to the helicopter, he lost his life."

The operation comes around two weeks after a similar attempt to rescue a boy from a Moroccan well gripped the world -- but ended with the child found dead.

Haidar's grandfather, 50-year-old Haji Abdul Hadi, told AFP the boy fell down the well when he was trying to "help" adults dig a borehole in the drought-ravaged village.

Officials said he fell to the bottom of the narrow 25-metre (80-foot) shaft, then was pulled by rope to within about 10 metres of the surface before becoming stuck.

Map locating the area in Afghanistan where rescuers were scrambling February 17 to reach a five-year-old boy trapped in a well for two days.
Map locating the area in Afghanistan where rescuers were scrambling February 17 to reach a five-year-old boy trapped in a well for two days. AFP / STAFF

They despatched bulldozers and other earth-moving equipment to the site, as well as one of the country's few airworthy helicopters in case he required medical evacuation to hospital.

Some Taliban officials posted videos of the tricky operation, saying it showed how the new regime -- widely criticised for rights abuses -- would spare nothing to care for its citizens.

"Our prayers weren't enough, but it brought everyone together, and we showed to everyone that all Afghan lives are precious," tweeted one Taliban official.

Video shared Thursday on social media showed the boy wedged in the well but able to move his arms and upper body.

"Are you OK my son?" his father can be heard saying. "Talk with me and don't cry, we are working to get you out."

"OK, I'll keep talking," the boy replies in a plaintive voice.

The video was obtained by rescuers who lowered a light and camera down the narrow well by rope.

Engineers using bulldozers dug an open slit trench from an angle at the surface to reach the point where Haidar was trapped.

A large rock blocked the final few metres, which workers used pickaxes to break through on Friday morning.

The operation employed similar engineering to the rescue attempt in Morocco earlier this month, when a boy fell down a 32-metre well and was pulled out dead five days later.

The ordeal of "little Rayan" gained global attention and sparked an outpouring of sympathy online, with the Arabic Twitter hashtag #SaveRayan trending.