Emergency vehicles arrive at the scene in Peshawar
A suicide car bomb attack on Pakistan's main intelligence agency in the city of Peshawar has killed at least 12 people and injured 40, officials say.
Another five people died in a separate suicide car bomb attack at a police station in the Baka Khel area in the North West Frontier Province.
The Peshawar blast destroyed the three-storey building of the Inter-Services Intelligence (ISI) agency.
The city has been frequently targeted by militants in recent weeks.
More than 100 people were killed in a blast at a market in Peshawar two weeks ago.
Attacks across Pakistan have dramatically increased as the army continues its offensive against the Taliban in the South Waziristan region.
"The bomber was asked to stop at a checkpoint next to the ISI offices here at 6.45 am," a military official told the BBC on the condition of anonymity.
The ISI building was severely damaged
"As he tried to use the car to force his way through, the guards outside opened fire on him.
"He then detonated the explosives."
Military authorities told the BBC say that over 60 people were injured in the attack. The said that the dead included seven military officials and three civilians.
The BBC's Abdul Hai Kakar in Peshawar says the explosion was so powerful it was heard by people within a 1km radius. Some thought it was an earthquake.
Our correspondent says that the ISI building was severely damaged and part of its structure has collapsed.
Syed Shoaib Hasan in Islamabad
Friday's attack makes it three weeks in a row that militants have struck the North West Frontier Province's capital on the Islamic week's holiest day. The targets are increasingly civilian.
It comes a day after the head of Pakistan's army said militants were striking back in civilian areas after failing to stand up to the military in battle. Since the insurgency started in earnest in 2007, militants have primarily targeted security installations.
The police and the ISI have been the target of particular ire - both organisations have been used as the main force to detain, interrogate and torture militant suspects since 9/11.
Many militants feel betrayed as the ISI was responsible for creating and nurturing the jihadis. While the attacks on public places suggest the militants are getting desperate, Friday's bombings show they are still able to hit security targets.
Officials says some people are still trapped under the debris. Army rescue teams are engaged in efforts to get them out.
Within minutes of the attack, the entire area was cordoned off by the military personnel who arrived on the scene.
The ISI offices are located off Khyber road in Peshawar city suburbs. The entire area is part of the military cantonment within city limits.
The checkpoint was located the entrance of the military cantonment area and it is not clear whether the bomber wanted to target the ISI or other sensitive military and civilian offices inside the cantonment.
These include the offices of North West Frontier Province's (NWFP) chief minister, governor and the head of Pakistan's military in the region.
At the time the blast took place, there was light traffic on the roads because it was early morning.
Correspondents say that if the attacker struck half an hour later, the death toll would have been much higher because the area would have been far busier.
As a result of the blast, however, schools have now been closed for the day in Peshawar.
"I was busy at work then suddenly I heard gunfire. I saw a vehicle moving towards the ISI building and then there was a huge blast. I was thrown to the ground," news agency AFP quoted Azmat Ali, a 30-year-old mechanic as saying.
"I don't remember anything else, but there was dust everywhere," he said.
Pakistani Prime Minister Yusuf Raza Gilani condemned the attack, saying his country's resolve to deal with militancy would not be weakened.
The last time an ISI building was targeted was in May, when 24 people were killed in a suicide attack in the eastern city of Lahore.
The blast at the Baka Khel police station in NWFP - less than 30 minutes later - killed three and wounded at least 15 people, police said.
Baka Khel is near Bannu town, close to the tribal region of North Waziristan, a Taliban stronghold.
"The bomber rammed his car into the police station," a Bannu police official told the BBC.
"Five people were killed and 16 injured in the attack."
The dead and injured were brought to hospitals in the town of Bannu, which is 20km from the site of the attack.
The latest attacks come one day after 17 Pakistani soldiers were killed in fighting in South Waziristan - the military's deadliest day since launching a major offensive there in mid October, security officials said.
The violence coincides with an attack by suspected Taliban militants on five Nato trucks transporting near Pakistan's south-western border with Afghanistan, police said.
Are you in Peshawar? Did you witness the explosion? Send us your stories using the form below.
You can also send us your pictures and videos to email@example.com or text them to +44 7725 100 100. If you have a large file you can upload here.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.