One Iranian aid agency said 70,000 people needed shelter after the quake, one of the largest this year.
Most of those who died were in Iran’s western Kermanshah province, officials told state media.
At least seven more died in Iraq, where people fled into the streets in the capital, Baghdad.
Mosques in the city have been broadcasting prayers through loudspeakers.
“I was sitting with my kids having dinner and suddenly the building was just dancing in the air,” a Baghdad mother-of-three, Majida Ameer, told Reuters news agency.
“I thought at first that it was a huge bomb. But then I heard everyone around me screaming: ‘Earthquake!'”
The Iranian news agency Isna quoted health officials as saying 2,500 people had been wounded.
Most of the victims were in the town of Sarpol-e Zahab, about 15km (10 miles) from the border, Iran’s emergency services chief, Pir Hossein Koolivand was quoted as saying on Iranian state television channel IRINN.
The town’s main hospital was severely damaged, leaving it struggling to treat hundreds of wounded, state TV reported.
Many homes in the mountainous area are made of mud bricks and are at risk of collapse in a significant earthquake like the one that struck on Sunday.
Damage was reported in at least eight villages, the head of Iran’s Red Crescent Organisation, Morteza Salim, told the channel.
“Some other villages have suffered power cuts and their telecommunications system has also been disturbed,” he said.
Rescue teams were being hampered by landslides, Mr Koolivand said.
On the Iraqi side, the most extensive damage was in the town of Darbandikhan, 75km (47 miles) east of the city of Sulaimaniyah in the Kurdistan Region.
“The situation there is very critical,” Kurdish Health Minister Rekawt Hama Rasheed told Reuters.
The Iraqi ministry of health said 321 people had been wounded in the Iraqi Kurdistan region.
The quake hit at 21:18 local time (18:18 GMT) about 19 miles (30km) southwest of Halabja, near the northeastern border with Iran, the US Geological Survey (USGS) said.
It occurred at a relatively shallow depth of 23.2 km (14.4 miles), and tremors were felt in Turkey, Israel and Kuwait. Iran sits across major fault lines and is prone to frequent earthquakes.
This story was originally published in BBC