The clashes were the heaviest in the area. Seventeen of the militants died when their vehicle was hit by fire by security forces, while the other sixteen died in separate incidents, chief military spokesman Major General Waheed Arshad told AFP.
"Helicopters were used in the operation. They shelled known militant positions on hill tops," Arshad said. "In one incident a vehicle carrying 17 militants was targeted, the vehicle fell from a hilltop and all were killed. They were militants, there is no doubt, they had arms," he added.
He said the two soldiers were killed and four others wounded when militants fired rockets that hit the airport at Saidu Sharif, one of the main towns in the Swat Valley. Security forces said two civilians were also killed.
One artillery shell landed in a house near the town of Matta killing a civilian and wounding six others including a woman and a 12-year-old boy, security officials said. A labourer was killed in a mortar attack in Kabal area as he unloaded sand from a truck, they said. None of the casualties could be independently confirmed.
Residents and security officials said troops used long-range guns against suspected militant bases while helicopters shelled their positions. Troops meanwhile arrested four militants carrying radio sets and grenades, Arshad said. "They are hardcore elements who were arrested after their messages were intercepted. We are investigating further their links," he added.
Unrest erupted in Swat in July when fugitive rebel leader, cleric Maulana Fazlullah, launched a campaign for the imposition of harsh Sharia law in the valley. Officials and witnesses said last week that the rebels had taken control of around two thirds of the valley.