Iranian rescue workers dug through rubble in a hunt for survivors on Monday after a major earthquake struck the Iran-Iraq border, killing more than 300 people and injuring thousands.
The 7.3-magnitude quake rocked a border area 30 kilometres (20 miles) southwest of Halabja in Iraqi Kurdistan at around 9:20 pm (1820 GMT) on Sunday, when many people would have been at home, the US Geological Survey said.
The worst affected areas were in Iran's western province of Kermanshah, where the coroner's office told state television that at least 336 people were dead and 3,950 injured.
Across the border in Iraq, in more sparsely populated areas, the health ministry said eight people had died and several hundred were injured.
Some Iranians spent the night outdoors after fleeing their homes in the mountainous cross-border region, huddling around fires at dawn as the authorities deployed help to affected areas.
A woman and her baby were pulled alive from the rubble in the Iranian town of Sar-e Pol-e Zahab, the worst hit in the quake, local media reported.
Officials said they were setting up relief camps but that access to the affected areas was not easy.
Iran's emergency services chief Pir Hossein Koolivand said it was "difficult to send rescue teams to the villages because the roads have been cut off... there have been landslides".
The official IRNA news agency said 30 Red Crescent teams had been sent to the quake zone, parts of which had experienced power cuts.
Iran's supreme leader Ayatollah Ali Khamenei ordered the government and armed forces to mobilise "all their means" to help.
Local media reported hundreds of ambulances and dozens of army helicopters mobilised for rescue operations including in rural areas.
After initially pinning the quake's epicentre inside Iraq, the USGS then placed it across the border in Iran on Monday morning.
Iran's Sar-e Pol-e Zahab, home to some 85,000 people close to the border, was the worst hit with at least 236 dead, while the towns of Eslamabad and Qasr-e Shirin were also affected.
Some 259,000 people live in the areas around these towns, according to the most recent census.
State television showed tents, blankets and food being distributed in areas hit by the quake.
At dawn on Monday in Sar-e Pol-e Zahab, buildings stood disfigured, their former facades now rubble on crumpled vehicles.
In an open space away from wrecked housing blocks, men and women, some wrapped in blankets, huddled around a campfire.
In Iraq, the health ministry said the quake had killed seven people in the northern province of Sulaimaniyah and one in Diyala province to its south.
More than 500 people were injured in both provinces and the nearby province of Kirkuk.
Footage posted on Twitter showed panicked people fleeing a building in Sulaimaniyah, as windows shattered at the moment the quake struck, while images from the nearby town of Darbandikhan showed walls and concrete structures that had collapsed.
In Darbandikhan, where four people were killed, officials called on residents to sleep outside as a precautionary measure.
Nizar Abdullah spent the night with neighbours sifting through the ruins of a two-storey home next door after it crumbled into concrete debris.
"There were eight people inside," the 34-year-old Iraqi Kurd said.
Some family members managed to escape, but "neighbours and rescue workers pulled out the mother and one of the children dead from the rubble".
Residents flee homes in Turkey
In Sulaimaniyah, residents ran out onto the streets and some damage to property was reported, an AFP reporter there said.
The quake, which struck at a relatively shallow depth of 23 kilometres, was felt for about 20 seconds in Baghdad, and for longer in other provinces of Iraq, AFP journalists said.
Iraqi health authorities said they treated dozens of people in the aftermath, most for shock.
On the Iranian side of the border, the tremor shook several cities in the west of the country including Tabriz.
It was also felt in southeastern Turkey, an AFP correspondent said. In the town of Diyarbakir, residents were reported to have fled their homes.
The quake struck along a 1,500-kilometre fault line between the Arabian and Eurasian tectonic plates, a belt extending through western Iran and into northeastern Iraq.
The area sees frequent seismic activity.
In 1990, a 7.4-magnitude quake near the Caspian Sea in northern Iran killed 40,000 people and left 300,000 injured and half a million homeless. In just seconds the quake reduced dozens of towns and nearly 2,000 villages to rubble.
Thirteen years later, a catastrophic quake struck the ancient southeast Iranian city of Bam, famed for its mud brick buildings, killing at least 31,000 people and flattening swathes of the city.
Iran has experienced at least two major quake disasters since, one in 2005 that killed more than 600 and another in 2012 that left some 300 dead.
More recently, a 5.7-magnitude earthquake near Iran's border with Turkmenistan in May killed two people, injured hundreds and caused widespread damage.