Four personnel of the Pakistan Army, including a major, lost their lives while attempting to foil a terrorist attack in Khyber Pakhtunkhwa's Upper Dir district in the early hours of Wednesday, said an Inter-Services Public Relations (ISPR) press release.

Major Ali Salman, who belonged to an intelligence agency, along with his team carried out an intelligence-based operation (IBO) against a terrorist hideout in in Sheratkal village of Sultankhel Darra, Upper Dir.

Military personnel carry the coffin of a soldier during a funeral ceremony in Peshawar. —AFP

When the security personnel raided the hideout, the suspected militants opened fire on the soldiers. One of the two suicide bombers present inside the hideout then blew himself up, while the other was killed in the exchange of fire with soldiers.

One suspected terrorist was apprehended during the operation, the ISPR statement said.

The martyred officer and soldiers were identified as Maj Ali Salman, Havaldar Ghulam Nazir, Havaldar Akhtar and Sepoy Abdul Karim.

Prime Minister Shahid Khaqan Abbasi expressed his grief over martyrdom of the army personnel, the Prime Minister's Office said in a statement.

Soldiers carry the coffin of Maj Ali during a funeral ceremony in Peshawar. —AFP

"Each drop of blood of our heroes is a testament to the fact that we all are united as a nation to cleanse our beloved motherland from terrorist elements," Abbasi said.

The incident comes as Operation Khyber-4, launched under Operation Raddul Fasaad (RuF) by the Pakistan Army in the Rajgal Valley area of Khyber Agency, gains momentum.

Terrorism in Pakistan

Incidents of terrorism in Pakistan have shown a drop over the three-year period from 2014-2017, the ISPR had announced earlier.

Trend in civilian casualties. ─ Photo courtesy ISPR

Since the launch of Operation RuF, the army has launched 46 major operations in the country and over 9,000 IBOs.

About 1,760 joint checkposts have been established in coordination with police and other law enforcement agencies.

An earlier version of this article erroneously said that the raid was carried out in Lower Dir. The error is regretted.