Islamabad, Pakistan (CNN) -- Two police officers were killed Monday morning in a suicide attack targeting a police compound in northwest Pakistan, officials said.
Six people were wounded during the attack, which occurred when hundreds of officers were inside the compound, police said.
The suicide bomber was among four militants who stormed inside the compound after opening fire at two guards manning the gate, said Abdullah Khan, the police chief in the district of Swabi.
A gunfight ensued inside the compound between the militants and police. The suicide bomber blew himself up during the gunfight, officials said.
The three remaining militants fled the compound, officials said. One of them was chased down and shot to death, police said.
The Pakistani Taliban claimed responsibility for the attack, Taliban spokesman Azam Tariq told CNN, saying the attack was revenge against security forces for the deaths of Pakistanis at the behest of the U.S. government.
"We will continue to take revenge for the killing of our innocent brothers," Tariq said.
The district of Swabi is about 70 kilometers (43 miles) northwest of Islamabad, just south of the Swat Valley and east of Pakistan's tribal region, where the Pakistani military has launched several operations against militants.
Journalist Nasir Habib contributed to this report.