The plane, which belonged to the Army's air force, was carrying 84 passengers and 10 crew, state television reported. At least 25 residents of the building were killed and more than a dozen injured.
"The building is on fire now," the television said, adding that fire-fighters were trying to save people trapped inside the building in the Azari residential district.
The C-130 aircraft hit the building while trying to make an emergency landing at Tehran's Mehrabad airport for an emergency landing, reports said.
The plane crashed into the Towhid residential complex.
It had taken off from Mehrabad airport and was heading to Bandar Abbas, a port city in southern Iran.
The Iranian air force is believed to have about 15 aging U.S.-made C-130s in operation, dating back to before the 1979 Islamic revolution and the U.S. boycott of Iran, reports the BBC. Officials blame the high frequency of crashes in Iran on a lack of aviation spare parts due to American sanctions.