An explosion in an underground gas pipeline in Haidian District at about 1 PM, started a fire in a neighbouring residential building, authorities said.
Fire fighters rescued eight residents trapped in the building and evacuated more than 160 others, state-run Xinhua news agency reported.
The blaze was put out around 2:30 PM with the help of 22 fire brigades.
Initial investigations suggest that the explosion was caused by construction workers accidentally damaging the pipeline.