Many soldiers and civilians were wounded in the blast
Lt Gen Sarath Fonseka is said to be in a stable condition after surgery in Colombo, where the attack happened.
The military has blamed Tamil Tiger rebels for the attack and launched air strikes on their positions in the east.
There has been a surge in violence in Sri Lanka recently, and the Tigers last week pulled out of planned peace talks.
Responding to the latest attack, President Rajapakse said he would not be cowed by terrorism.
"I emphasize and caution that one should avoid mistaking our desire for peace and our responsibility to achieve it as a government, as weakness," he said in a televised address.
This is the first suicide bombing in the Sri Lankan capital since July 2004, and the biggest attack blamed on the Tamil Tigers since they signed a truce with the government in 2002.
Though the ceasefire still officially holds, Sri Lanka appears to be heading back to war, the BBC's Dumeetha Luthra reports from Colombo.
Fake identification
Military officials say the attacker was a woman who made herself appear heavily pregnant to conceal the explosives.
She presented fake identification and said she had an ante-natal appointment at the army hospital inside the complex, unnamed officials told the Associated Press news agency.
Lt Gen Sarath Fonseka has taken a hard line against the Tigers
A Sri Lankan military spokesman who spoke to the BBC said the attacker blew herself up as Lt Gen Fonseka was leaving his office "just in front of the army hospital".
Twenty-seven people were wounded in the attack, the army said.
It is not clear if the bomber was included among the eight people said by the military to have been killed in the blast.
The army headquarters are in a heavily guarded compound in central Colombo.
Lt Gen Fonseka is reported to have suffered severe abdominal injuries and was taken to hospital.
A team of 10 surgeons operated on him and he is now said to be in a stable condition.
Lt Gen Fonseka was appointed head of the army shortly after the election of President Mahinda Rajapakse last November and has taken a hard line against the Tamil Tigers.
HAVE YOUR SAY No-one here believes it is a suicide attack as the headquarters is heavily-guarded and all are searched even if they are pregnant
Ajantha Rajasinghe, Colombo, Sri Lanka
Send us your comments
The Sri Lankan military says it has begun an aerial assault on rebel positions in north-eastern Sri Lanka, telling the BBC it could not stand by after the attack on its headquarters.
The military said the Tigers had earlier attacked Sri Lankan naval positions in the north-eastern district of Trincomalee.
A Tamil Tiger leader in Trincomalee, Mr Ezhilan, told the BBC that civilians in the area had been fleeing shelling by the army.
COLOMBO ATTACKS August 2005: Foreign Minister Lakshman Kadirgamar shot dead at his home July 2004: Woman suicide bomber tries to kill government minister July 2001: 18 people killed and planes destroyed in attack on Colombo airport
In pictures: Sri Lanka blast
Police said the explosion in Colombo bears all the hallmarks of the Tigers.
Tamil Tiger rebels frequently use suicide bombers in their operations - and are thought to have carried out nearly 200 attacks since the first suicide bombing in July 1987, when a bomber in a truck filled with explosives killed 40 soldiers.
The rebels have denied being behind recent attacks.
Talks on hold
Escalating violence in the north and east of the country has left about 100 people dead in the past three weeks.
The Tigers began their armed campaign for a separate homeland for the island's Tamil minority in the 1970s.
Efforts are continuing to persuade the rebels to return to peace talks in Switzerland. Last week they pulled out of negotiations, accusing the government of attacks on ethnic Tamil civilians.
The team of Norwegian envoys acting as mediators in the conflict has condemned the latest bombing, but said it was not drawing "any immediate conclusions about the possible perpetrators".
The Sri Lankan Defence Secretary, Gothabaya Rajapakse narrowly escaped a suicide attack from suspected Liberation Tigers of Tamil Eelam (LTTE) rebels. The attack took place in downtown Colombo, the Sri Lankan Capital at 10:30 a.m., as a convoy carrying the Defence Secretary and other officials was attacked by a suspected terrorist in a three wheeler. 

Early reports indicate that Gothabaya, brother of Sri Lankan President Mahinda Rajapakse and vocal critic of the LTTE, escaped unscathed, while at least 2 people have died and 14 others were injured, including 5 civilians. 

While the LTTE has yet to claim responsibility for the latest strike, the militant separatist group, proscribed as a terrorist organisation in countries such as the United States, England, India, Australia and the E.U., has yet to do so for any of the suicide attacks attributed to them throughout their history. In 2006 alone the group has been accused of carrying out suicide attacks on unarmed Sri Lankan servicemen in Habarana and on a naval base in the tourist city of Galle, as well as failed attempts on the lives of Lieutenant General Sarath Fonseka and Pakistani Ambassador to Sri Lanka, Bashir Wali Mohamed. 

The latest suicide attack comes just days following a declaration from LTTE leader, Velupillai Prabhakaran, that the Norway brokered ceasefire agreement with the Sri Lankan government was ‘defunct’.