One person has died of a heart attack and at least 56 people were injured after a 4.2 magnitude earthquake struck 50km west of Tehran, according to state media.

Most of the injured were trying to escape buildings and were released from hospital after treatment, Iran's Emergency Medical Services said.

The earthquake, which struck at 12.54am local time, was an aftershock of a bigger 5.2 magnitude quake on 20 December, which left two people dead.

Tremors were also felt in the capital on Wednesday morning. Many residents spent the night in cars, sports centres and other buildings turned into rescue centres, local media reported.

Some schools in western Tehran and the city of Karaj are reportedly closed and exams were cancelled.

It comes six weeks after a 7.2 magnitude earthquake hit the country and became the deadliest of 2017, killing more than 620 people.