ISLAMABAD (Reuters) - A suicide bomber killed four Pakistani soldiers in an attack in the troubled northwest near the border with Afghanistan, the army said on Wednesday, at least the second major attack since Prime Minister Shahid Khaqan Abbasi came to power a week ago.

Pakistan began a military offensive against fighters affiliated with the Islamic State group along the northern part of the border last month, saying the region was fast becoming a safe haven for multiple terrorist organizations.

An army patrol was conducting a search operation in Upper Dir on Tuesday night, near the Malakand region where the Pakistani Taliban had controlled large swaths of territory until a military operation in 2009.

‎”The military officials received information about the presence of terrorists in the area,” the military said in a statement. They were conducting a search operation “when one of the terrorists blew himself up”.

The Tehreek-e-Taliban Pakistan (TTP), also known as the Pakistani Taliban, claimed responsibility for the attack in a message sent to the media.

“Our fighters attacked them when they were on the way and killed a major and other soldiers,” said TTP spokesman Mohammad Khurassani.

The Pakistani military said an officer and three soldiers were killed in the attack, which drew immediate condemnation from Abbasi.

“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,” the prime minister’s office said in a statement.

A security official who asked not to be identified told Reuters that security forces were drawn into a gun battle with two militants when one of the men blew himself up.

“This area is infamous for its record of terrorist activities,” the official said.

Abbasi took office last week after previous premier Nawaz Sharif was disqualified by the Supreme Court over undeclared assets, a ruling Sharif has decried as politically motivated but opposition leaders say was a victory for the rule of law.

At least 22 people were wounded in a bombing in the restive eastern city of Lahore on Tuesday, a government official said, although there was no claim of responsibility for that attack.