At least 20 firefighters have died after a major commercial building in Iran's capital, Tehran, collapsed following a huge fire, according to the city's mayor.

The confirmation of the death toll by Iranian politician Mohammad Baqer Qalibaf came after conflicting casualty reports earlier on Thursday, with some state media outlets initially reporting dozens of deaths but later backtracking.

Firefighters battled the blaze for several hours before the building, just north of the capital's sprawling bazaar, fell. Police tried to keep out shopkeepers and others wanting to rush back in to collect their valuables.

The building came down in a matter of seconds, shown live on state television, which had begun an interview with a journalist at the scene. A thick plume of brown smoke rose over the site after the collapse.

More than 200 people injured in the fire were transferred to medical facilities, IRNA news agency reported.

Hundreds of people have queued up in hospital and clinics to donate blood, while several firefighters are reported to have been trapped in the basement of the collapsed commercial complex.

Fars news agency reported that a firefighter had sent a text message to a colleague, saying he was alive and trapped with several others at the building's engine room.

Army special forces were deployed to aid the search and rescue efforts.

Fars quoted sources saying some 30 firefighters had "most likely" been killed and that the toll was likely to rise as many people were trapped in the building when it came down.

The 17-storey building, dating from the early 1960s and including a shopping centre and clothing workshops, was among the first high-rises built in the Iranian capital..

Dramatic images showed flames pouring out of the top floors before it crumbled to the ground.

"We had repeatedly warned the building managers about the lack of safety of the building," fire brigade spokesman Jalal Malekias said, adding that it lacked fire extinguishers.

"Even in the stairwells, a lot of clothing is stored and this is against safety standards. The managers didn't pay attention to the warnings," he said.