The shallow quake hit 26 kilometres (16 miles) southwest of the city of Javanrud in Kermanshah province, the US Geological Survey said, near the site of a powerful quake last year that killed hundreds.
The head of the emergency department Kermanshah University of Medical Sciences, Saeb Sharidari, told state news agency IRNA that two people were killed and 241 people injured, six critically.
Sharidari said the two dead were a pregnant woman and a 70-year-old man who died of a heart attack.
The provincial head of the Red Crescent, Mohammad Reza Amirian, said there had been at least 21 aftershocks.
He said there were potential problems with drinking water due to damaged infrastructure in villages, but that it had not yet been necessary to distribute food and tents.
Kermanshah governor Houshang Bazvand told the Tasnim news agency that electricity had been temporarily cut to several villages.
A crisis centre was set up, with hospitals and relief organisations placed on alert.
But the local director of crisis management, Reza Mahmoudian, told the Mehr news agency that "the situation was under control" and no request for help had been sent to neighbouring provinces.
There were reports that the quake was felt far across the border into Iraq.
Images on social media showed people being rushed to hospitals, but suggested relatively light damage to infrastructure.
Iran sits on top of two major tectonic plates and sees frequent seismic activity.
In November last year a major 7.3-magnitude quake killed 620 people in Kermanshah province and another eight people in Iraq.