An Afghan man taken hostage by the Taliban made a dramatic escape by stealing a gun while his captors were praying and shooting dead seven of them and wounding 18 others, officials said Thursday.

Awal Khan and a local police officer were kidnapped Wednesday as they were driving in the eastern province of Paktika, provincial deputy security chief Abdul Rauf Masood told AFP.

Paktika is a Taliban stronghold bordering Pakistan.

The officer was killed and 36-year-old Awal taken to a Taliban compound in Gomal district where he was held for hours.

During afternoon prayers, Awal, who Masood said was handcuffed at the time, grabbed a weapon belonging to one of his captors and opened fire.

“Awal Khan sprayed bullets on all of them, killing seven and wounding 18 others,” provincial governor spokesman Mohammad Rahman Ayaz told AFP.

Taliban spokesman Zabihullah Mujahid confirmed to AFP that the group had kidnapped the two men and that Awal had opened fire on the militants, killing three of them.

Awal then fled in a pickup truck belonging to his kidnappers, Ayaz said.

His brother, a local police commander, shared details of the incident with authorities.

The Taliban is often involved in kidnappings of Afghans and foreigners, sometimes holding people for years for prisoner exchanges.