The militants who led the attack on a Kenyan mall hired a shop there in the weeks leading up to the siege, senior security sources have told the BBC.
This gave them access to service lifts at Westgate enabling them to stockpile weapons and ammunition.
Having pre-positioned weapons they were able to re-arm quickly and repel the security forces.
Sixty-seven people are known to have died in the four-day siege. Kenya’s Red Cross says 61 others are still missing.
Forensic experts are still combing the complex, looking for bodies and clues.
The Somali Islamist group al-Shabab, which is part of al-Qaeda, says it was behind the attack and the following siege at the upmarket mall in the Kenyan capital, Nairobi.
is in its third day of official mourning for both the civilian and military victims of the attack.
The BBC investigation has revealed how the Westgate gunmen were able to plan and carry out the siege, and how security breaches allegedly fuelled by corruption made it an attack waiting to happen.
To rent a shop, the militants would have needed fake IDs supplied by corrupt government officials.
The BBC has also confirmed more details about how they executed their attack.
Two vehicles dropped the Islamist extremists off outside before they forced their way into the mall, sources say.
They are also believed to have set up a base using a ventilation shaft as a hiding place, on the first floor.
Security sources have also confirmed a change of tack by the militants late on Saturday.
They rolled out heavy calibre machine guns, exploiting the moment when control of the security operation switched from the police to the military.
There are reports that this switchover was fraught with confusion.
The heads of the various security agencies have been summoned to appear before the parliamentary defence committee on Monday, amid rising concern over the authorities’ preparedness for such an attack.
The committee’s chairman, Ndung’u Gethenji, told the BBC that “people need to know the exact lapses in the security system that possibly allowed this event to take place”.
He also said they needed to understand “the anatomy of the entire rescue operation” amid the allegations of confusion over who was in charge.
It is still not clear how many militants took place in the attack or their nationalities.
But senior sources within al-Shabab, which has repeatedly threatened attacks on Kenyan soil if Nairobi did not pull its troops out of Somalia, told the BBC by phone that they would not release the attackers’ names.
A senior government official told the Associated Press news agency that the army had caused the collapse of a section of the mall on Monday.
The official, who did not want to be named, said autopsies would show whether this had killed the hostages or whether they had already been murdered.
Correspondents say there have been reports that the military had blown out a supporting column to bring the siege to an end – a controversial decision which, if confirmed, would raise the possibility that hostages’ lives were seen as expendable.
Irene Anyango, manager of a Westgate jewellery shop, is one of the few people who has been allowed into the mall following the end of the siege.
“It was a nightmare… and the shop was a totally different place,” she told the BBC.
Ms Anyango said 90% of the jewellery was missing from the shop, which is now flooded.
“As far as we know, for the last couple of days they were intact – we don’t understand what’s happening but they’re not there,” she said.
Many people not only face the trauma of losing family and colleagues but also the possibility of losing their jobs, she added.
On Friday morning, President Uhuru Kenyatta attended the funeral of his nephew and his nephew’s fiancee at a church service Nairobi, where he addressed the congregation.
Mbugua Mwangi and Rosemary Wahito were among those killed in the mall on Saturday.
About 4,000 Kenyan troops have been sent to Somalia to help pro-government forces battle al-Shabab.
The group is banned as a terrorist group by both the US and the UK and is believed to have between 7,000 and 9,000 fighters.
Its members are fighting to create an Islamic state in Somalia.