The Taliban hung the bodies of four kidnappers from cranes after killing them during a shootout in Afghanistan's western city of Herat, a senior official said.

Herat province's deputy governor Mawlawi Shir Ahmad Muhajir said the men's corpses were displayed in various public areas on the same day as the killings to teach a "lesson" that kidnapping will not be tolerated.

Graphic images posted to social media showed bloody bodies on the back of a pick-up truck while a crane hoisted one man up.

A crowd of people looked on as armed Taliban fighters gathered around the vehicle.

Another video showed a man suspended from a crane at a major roundabout in Herat with a sign on his chest reading: "Abductors will be punished like this".

The display across several squares in the city is the most high-profile public punishment since the Taliban swept to power last month.

It is a sign the Islamist hardliners will adopt fearsome measures similar to their previous rule from 1996 to 2001.

Mr Muhajir said security forces were informed a businessman and his son had been abducted in the city this morning.

Police shut down the roads out of the city and the Taliban stopped the men at a checkpoint, where "an exchange of fire happened", he said.

"As a result of a few minutes of fighting, one of our Mujahideen was wounded and all four kidnappers were killed," Mr Muhajir said in a recorded statement sent to AFP.

"We are the Islamic Emirate. No one should harm our nation. No one should kidnap," he said in the video clip.

The two kidnapping victims were released unharmed.

Mr Muhajir added that that before the incident there had been other kidnappings in the city, and the Taliban rescued a boy.

One kidnapper was killed and three others were arrested, he said, although in another case the Taliban "failed and the abductors were able to make money".

"It saddened us a lot because while we are in Herat, our people are being abducted," Mr Muhajir said.

"In order to be a lesson for other kidnappers not to kidnap or harass anyone, we hung them in the squares of the city and made this clear to everyone that anyone who steals or abducts or does any action against our people will be punished."

In an interview with the Associated Press published this week, senior Taliban figure Mullah Nooruddin Turabi said the group would restore punishments like amputations and executions to deter criminals.

The US, which condemned Mr Turabi's reported comments on punishments, has said any potential recognition of the Taliban-led government in Kabul would depend on respect for human rights.