Hours earlier, a suicide bomber killed 45 people and wounded more than 70 at a rally by a secular political party in the northwest that has supported recent Pakistani army offensives in the region close to Afghanistan, where the United States is battling a related insurgency.
The attacks follow a lull in violence since the beginning of the year, illustrating the militants' resilience.
The multi-pronged strike against the consulate in Peshawar city was the first direct assault on a U.S. mission in the country since 2006. Officials said the four attackers in two vehicles hoped to breach the heavily fortified compound and kill people inside, but they failed to do that and caused only minor damage.
They detonated their first suicide vehicle at a checkpoint some 20 meters (yards) from the entrance to the consulate, said Peshawar police chief Liaquat Ali Khan. The second vehicle, which was carrying a larger amount of explosives, was stopped at another security barrier some 15 meters (yards) from the entrance, he said.
"The driver had no option, but to detonate the vehicle right there," said Khan.
The second blast killed two militants wearing suicide vests who were walking ahead of the pickup truck, said Khan.
Some officials and witnesses reported a third or possible fourth explosion. The blasts, some of which were filmed by local television stations, sent huge mushroom clouds over the city. One piece of footage showed a bomb exploding several meters (yards) from two people who had their arms raised in the air as if surrendering.
In Washington, a White House spokesman condemned the blasts.
U.S. Secretary of State Hillary Rodham Clinton said in a statement that she was "outraged and deeply saddened" by the attack.
"The assault this morning is part of a wave of violence perpetrated by brutal extremists who seek to undermine Pakistan's democracy and sow fear and discord," Clinton said. "The Pakistani people have suffered grievous losses, but they are standing firm in the face of this intimidation - and the United States stands with them."
The style of the attack - multiple suicide bombs and attackers with conventional weapons - has become an increasingly common one both in Pakistan and Afghanistan.
The attackers who fired at the consulate were wearing security uniforms, another tactic insurgents have used in both countries to slip into guarded areas, said a Pakistani intelligence official, speaking on condition of anonymity because he was not authorized to talk to the media.
The four people killed in the attack included three security personnel and one civilian, said Khan. Two of the security personnel were employed by the consulate, said the embassy. The third was a Pakistani paramilitary soldier, said police official Sattar Khan.
Pakistani Interior Minister Rehman Malik said the Pakistani Taliban claimed responsibility for the attack.
Last week, Waliur Rehman, a senior militant commander warned the insurgents were preparing more strikes.
"We know our enemy and will target its installations and facilities for which our special wing is fully ready," he said in an interview in the tribal regions a few hours' drive from Peshawar. "Pakistan has initiated army action in tribal areas to please America. Now the whole of Pakistan is like a battlefield for us."
Al-Qaida and Taliban militants have long had their sights set on the U.S., which has fired scores of missiles at them in their northwestern strongholds over the last 1 1/2 years. Washington has also given billions of dollars in aid to the Pakistani army.
Family members of people assigned to the American embassy in Islamabad and the country's three other consulates in Pakistan were ordered to leave in March 2002 and have not been allowed to return.
The U.S. is only one of three countries to have a diplomatic presence in Peshawar, which has seen repeated militant attacks over the last 18 months. The city is the largest in the northwest and home to its regional government and security force commands.
It has long been a vital hub for American interests in the region.
Much of the funds that were handed to Afghans fighting Soviet rule in Afghanistan in the 1980s were channeled through the city. Post Sept. 11, its proximity to the tribal areas, a likely hiding place for Osama bin Laden, has meant it is vital for U.S. officials to be stationed there. The mission is also important for coordinating the millions of dollars in development funds Washington is spending to try to dry up support for militancy in the desperately poor and badly governed tribal regions.
In August 2008, the top U.S. diplomat at the consulate survived a gun attack on her armored vehicle. Three months later, gunmen shot and killed an American in Peshawar as he was traveling to work for a U.S.-funded aid program in the region.
The last attack against a U.S. mission in Pakistan was in Karachi in 2006 when a militant rammed an explosives-laden vehicle into the car of an American diplomat near the consulate, killing him and three others.
Shortly before Monday's attack, a suicide bomber struck a rally held by a Pashtun nationalist party in Lower Dir to celebrate the government-supported proposal to change the name of North West Frontier Province to Khyber-Pakhtoonkhwa, said local police chief Mumtaz Zarin Khan.
"A police official spotted the bomber a second before he exploded," said Khan. "The official shot at him, but by that time, he had done his job."
He said 45 people at the rally in the town of Timergarah were killed and 77 wounded.
"Such acts only reflect the barbarian approach of the militants," said an Awami National Party lawmaker from the district, Malik Azmat. "They are not humans."
Lower Dir lies next to the Swat Valley, which was the target of a major military offensive last year that succeeded in driving out the militants. Other major operations in the Afghan border region followed, including one in the Pakistani Taliban's tribal stronghold of South Waziristan.
The frequency of militant attacks in Pakistan over the last three months has dropped compared to the final quarter of last year, but experts have cautioned it is far too early to say this means the insurgents are in retreat.
"It seems that those who have been disrupted or dismantled and denied space in the Waziristan region finally managed to reorganize themselves at least for these attacks in Peshawar," said Imtiaz Gul, director of the Center for Research and Security Studies in Islamabad.
Associated Press Writer Sherin Zada contributed to this report from Timergarah and Matthew Lee contributed from Washington.