Mulwi Shir Ahmad Ammar, the city's deputy governor, said the four men had kidnapped a local trader and his son Saturday morning and had intended to take them out of the city, about 500 miles west of the capital, Kabul.
They were killed during an exchange of gunfire that left one Taliban fighter wounded, he said, adding that their bodies were strung up "in order to be a life lesson for other kidnappers."
Authorities had set up roadblocks and checkpoints across the city to catch them, he said. NBC News was not able to independently verify his claims.
Download the NBC News app for breaking news and politics
Video of a corpse swinging on the crane in broad daylight in Mostofiat Square was widely shared on social media and by news agencies. Crowds mostly of men could be seen looking up at the body.
No other bodies were immediately visible in the video, but social media posts said others were hung up in other parts of the city.
A senior Taliban commander said public execution was "the only solution" to deal with crimes, particularly kidnapping and murder. He spoke on condition of anonymity because he was not officially authorized to speak.
After the group seized control of the country last month, Afghans and the world have been watching to see whether the Taliban will bring back the harsh rule of the late 1990s, which saw public stonings and limb amputations of alleged criminals, some of which took place in front of large crowds at a stadium.
Even though the Taliban are trying to paint an image of a more tolerant and modern regime, evidence has increasingly pointed to a broad and sometimes brutal crackdown since the militants took back control, as they settle old scores, stamp out opposition and try to force many Afghans to adhere to their strict interpretation of Islam.
Last week, one of the founders of the Taliban, Mullah Nooruddin Turabi, the chief enforcer of its harsh interpretation of Islamic law when they last ruled Afghanistan, said the hard-line movement will once again execute people and amputate hands, prompting strong condemnation from the U.S.
State Department spokesman Ned Price said in a briefing Friday that the U.S. would "stand firm with the international community to hold perpetrators of these, of any such, abuses accountable."
Washington has repeatedly said any recognition of the new Taliban government would be contingent on the militants' upholding human rights.