Acting on a tip-off, the security forces and the police carried out the raid in Swat's Charbagh area in Khyber Pakhtunkhwa province, they said.
The militants, top commanders of the outlawed Tehrik-e- Taliban Pakistan (TTP), opened fire after which the security forces killed them.
Both the militants were wanted by the police in cases of targeted killings and terror attacks, the police said.
"The militants were being traced for their previous involvement in terrorist activities in Malakand division," the army said in a statement.
According to the security forces, the militants were in contact with the TTP leaders in Afghanistan.
Disclaimer: No Business Standard Journalist was involved in creation of this content