The two raids that left two Pakistani soldiers dead took place in Khyber Pakhtunkhwa province's Swabi district, just 100 kilometres (60 miles) northwest of Islamabad

At least 15 militants and two soldiers have been killed in two separate gun battles in a relatively peaceful district of Pakistan just northwest of the capital Islamabad, officials said Wednesday.

The shootouts come after a recent resurgence in militant violence, with 130 people killed nationwide in the month of February, ending a lull in Pakistan's long battle against homegrown Islamist fighters.

The two raids took place in Khyber Pakhtunkhwa province's Swabi district, which is just 100 kilometres (60 miles) northwest of Islamabad and far from the border tribal areas that have been the main battlefront over the course of the insurgency.

Soldiers on Tuesday conducted a raid on a village in the district, triggering a gunfight.

"During exchange of fire Capt Junaid and Sepoy Amjad embraced martyrdom," said a military statement, adding: "Five terrorists killed during the operation."

Security forces stormed a second compound in a nearby village on Wednesday, killing 10 militants, a senior security official told AFP.

No details regarding the second shootout have yet been released, but the incident came to light after police and security forces brought 10 bullet riddled bodies to a local hospital.

"They were militants and killed during an intelligence based operation," the senior security official told AFP.

Separately, the military said that five Taliban militants who had been sentenced to death were executed on Wednesday at a prison in northwestern garrison town of Kohat.

Pakistan created special military courts by constitutional amendment after the country's deadliest ever extremist attack in 2014.

The assault on a school in northwestern Peshawar, in which gunmen killed more than 150 people -- mostly children -- traumatised a country already grimly accustomed to atrocities.

The law allowing secret military courts to try civilians on terror charges expired in January, after the controversial tribunals hanged 12 people and ordered the executions of 149 more amid sharp criticism from rights groups. The government is mulling resuming military courts after a fresh constitutional amendment.

Pakistan's military announced the launch of a nationwide anti-terrorist operation in the wake of the violence last month.

The attacks, most of which were claimed by the Islamic State group or the Pakistani Taliban, dented optimism after the country appeared to be making strong gains in its decade-and-a-half long war on militancy.