In Tehran and other cities and towns, the quake sent panicked residents into the streets and parks.
Authorities asked residents to remain calm but said to be prepared for possible aftershocks.
Some residents set up tents to spend the night outside and lit fires.
Gasoline purchases in the six hours after the earthquake reached 10 million liters, more than double the average full-day sales even though it was the middle of the night, the national fuel distributor said.
But not everyone stocked up on essential supplies.
Some Tehran residents found refuge in their cars and sought safer ground or just ran their engines for warmth in the cold conditions.
Iran lies on a plateau that is highly susceptible to tectonic activity. Hundreds of people were killed in a November earthquake on the Iran-Iraq border that is still fresh in people's minds.
Schools, universities, and government offices would be closed in Tehran, Alborzn, and Qom provinces on December 21, state television said.
People started slowly returning to their homes again early on December 21.