A gang of Islamist insurgents launched a daylight raid on the US consulate in the Pakistani city of Peshawar, trying to storm the building armed with guns and suicide belts.
Army soldiers took battle positions on the city's main Khyber Road, where the attack unfolded.
Military helicopters scoured the streets from above looking for any insurgents who might have escaped. The Pakistani Taliban said it carried out the raid, promising more attacks and stating: "Americans are our enemies".
Police told the BBC four militants and three security personnel died in the raid.
There were three explosions and nearby buildings collapsed, although it is not clear if the consulate building itself suffered any damage.
The BBC's correspondent in Pakistan says it was the first attack against a US facility in Pakistan in four years.
As the attackers struck, they sent plumes of smoke billowing over the city, which lies in Pakistan's violent tribal belt.
Police suspect the attack was co-ordinated with a suicide attack which killed more than 40 people earlier in the day at a crowded political rally not far away in Timergara, Lower Dir.
What are these?