People living in the six-storey building said an explosion woke them up in the early hours of Friday.
Several people have been injured, said Banani Police Station SI Zahirul Islam.
Three have been admitted to a Gulshan hospital.
One among them has sustained burns but the rest were wounded while trying to rush out of the building.
The building at Banani’s Road No. 23 caught fire around 2am Friday, said Fire Service Official Mizanur Rahman.
Its residents ran up to the roof for safety and were left stranded, as flames spread from the third to the sixth floor.
Twenty-five people were rescued from the rooftop.
Fifteen firefighting units worked until 3:30am to douse the fire, Fire Service Director (Operation) Maj AKM Shakil Newaz told reporters.
“We’ll investigate the cause of the fire. But we found a leak in the gas line under the building.”
A resident from the fourth floor said he woke up because of a loud explosion around 2am. The glass windows were shattered and household items were scattered all around.
He then ran to the roof when he saw the fire, he said.
The residents said gas had been leaking from a sewerage line under the building for several days, and had complained to the authorities.
The apartments on the south side were mostly damaged in the fire, said bdnews24.com reporter Kamal Talukder, who went to the site in the morning.
Naser Mohammad Khan, who lives in a north-facing apartment on the first floor, said, “I heard an explosion around 2am and I saw fire everywhere. Me, my wife and our three children quickly took the stairs down.”
The building’s owner Shamsul Alam lives on the third floor. His son was burnt in the fire, said Khan.
A woman from the building said they had called Titas, the distribution company, around 11:30pm but were told there were no ‘workers’ to fix the leak.
Titas Gas Deputy Director Harun Ur Rashid later told reporters about the manpower shortage. But Titas men went to the area to turn off the gas around 3am after the fire started.
Dhaka North City Corporation Mayor Annisul Huq was at the spot, supervising the fire-fighting effort. He used a hand-held mike to communicate with those trapped from the roof of a nearby building.
He went inside with the fire fighters after the blaze was doused.
On Feb 26, four members of a family had died after a gas leak caused a fire in their home inside a seven-storey building at Dhaka’s Uttara.