The militants were arrested in Matta area of Swat following a tip-off from local residents a few days ago, an official of the army-run media center in Swat said.
He said the militants had told security forces that they had stored their arms in the mountainous area of Darosh Khel.
The troops took the militants to identify the location "But they tried to snatch arms from the soldiers and to escape," the official said. The troops then fired at the militants and killed them.
The bodies of the militants were handed over to police, who shifted them to a hospital for identification, the official said.
However, local residents said the slain militants were arrested during a military operation in Swat in 2009. Hundreds of militants, civilians and security personnel were killed in the operation.
Nearly two million people fled Swat and nearby Buner district as the result of the fighting and the army cleared the areas after an operation lasting several months.
Several international and Pakistani rights groups have disputed claims by the security forces that detained militants have been killed while trying to flee.
They allege that the security forces have carried out extra-judicial killings and demanded an independent inquiry into such incidents. The army has denied all such allegations.