Hours after the attack, the world body said it was closing its offices in Pakistan temporarily.
"This is a heinous crime committed against those who have been working tirelessly to assist the poor and vulnerable on the front lines of hunger and other human suffering in Pakistan," U.N. Secretary-General Ban Ki-moon told reporters in Geneva.
Ban said the U.N. will continue its humanitarian assistance to more than 2 million Pakistanis. WFP spokesman Amjad Jamal said the food agency would not halt its aid to refugees fleeing fighting between militants and the army even while its offices were shut. "I want to repeat it again that our operations have not been halted."
There was no immediate claim of responsibility for the bombing. Militants have carried out scores of suicide attacks in Pakistan over the last 2½ years, several of them targeting foreigners and their interests. Under U.S. pressure, Pakistani security forces have recently had some success combatting the extremists.
Islamist militants in Pakistan, Afghanistan and Iraq seeking to attack high-profile Western targets have shown no hesitation in targeting foreign humanitarian agencies, including the United Nations, regardless of the work they are doing in relieving the suffering in the countries.
The blast Monday shattered windows in the lobby of the compound in an upscale residential area of Islamabad and left victims lying on the ground in pools of blood, witnesses said. The office is close to a home belonging to President Asif Ali Zardari.
Security camera footage broadcast on local TV shows the bomber walking through a door into what appears to be the main building carrying a two-foot- (half-meter-) long cylindrical object - possibly a detonator - in one hand. Seconds later, a bright flash fills the screen.
"There was a huge bang, and something hit me. I fell on the floor bleeding," said Adam Motiwala, an information officer at the U.N. agency who was hospitalized with injuries to his head, leg and ribs.
Medical officials at two hospitals said five people had been killed in the attack, including an Iraqi working for the agency. Two of those killed were Pakistani women. Several others were injured, two of them critically, the WFP said in a statement.
Interior Minister Rehman Malik said the attacker was wearing the uniform of a paramilitary police officer and asked a guard if he could go inside the building to use the bathroom. He was carrying around 8 kilograms (18 pounds) of explosives.
Police official Bin Yamin said the attacker, who was in his 20s, detonated his explosives in the lobby. It was unclear how he made that far. Typically, visitors to U.N. buildings in Islamabad are screened and patted down for weapons and explosives in secure chambers some distance from the entrance to the building.
U.S. Ambassador Anne Patterson condemned the targeting of aid workers as an attack against Pakistani society.
"Such cruel acts expose the true nature of the terrorists' agenda," she said.
The bombing was the first such attack in Islamabad since June, when two police where killed. Another blast in June on a luxury hotel in the northwestern city of Peshawar killed two U.N. staffers and injured others.
On Sunday, Hakimullah Mehsud, the new leader of the Taliban in Pakistan, met with reporters in the country's tribal areas for the first time since winning control of the militants. His appearance, flanked by other Taliban commanders in a show of unity, ended speculation that he was killed in a leadership battle within the militant group sparked by the August slaying of his predecessor, Baitullah Mehsud, in a missile strike.
"We all are sitting before you which proves all the news about myself ... was totally baseless and false," he said.
Mehsud spoke to a small group of reporters as he sat on a blanket on the ground in the shade of a tree, flanked by guards carrying heavy machine guns and rocket-propelled grenade launchers.
He spoke on condition his comments not be published until the reporters left the area Monday out of concern their use of satellite phones to file the story could lead Pakistani forces to him.
Mehsud vowed to strike back at Pakistan and the U.S. for the increasing number of drone attacks in the tribal areas along the border with Afghanistan.
Unmanned drones have carried out more than 70 missile strikes in northwestern Pakistan over the last year in a covert program, killing several top militant commanders along with sympathizers and civilians. The Pakistani government publicly protests the attacks but is widely believed to sanction them and provide intelligence for at least some.
Pakistan has largely beaten back a Taliban insurgency in the northwestern Swat Valley in recent months and intelligence officials say the country is preparing a major offensive against al Qaeda and Taliban in their stronghold in South Waziristan.
Mehsud said his forces were ready for such an attack.
American officials have said they are considering a strategy of intensified drone attacks combined with the deployment of special operations forces against al Qaeda and Taliban targets on the Pakistani side of the border - part of an alternative to sending more troops to Afghanistan in what is an increasingly unpopular war.
As part of the offensive against the Taliban leadership, Mehsud's brother, Kalimullah, was killed last month. Analysts say the group is struggling to regroup from the attacks on its leaders.