An earthquake in the border area between Iran and Iraq has killed hundreds of people and injured thousands of others, according to Iranian officials.

The 7.3 magnitude quake on Sunday hit the Iraqi town of Halabjah, southeast of Sulaymaniyah, a city in the semi-autonomous Kurdish region of northern Iraq.

Tremors were felt across Iraq, parts of Iran, and as far away as Lebanon and the Gulf state of Qatar.

The initial reaction on social media was one of confusion as people tried to make sense of what they had just felt.

As details became clearer, confusion gave way to shock as images emerged of destroyed buildings in the areas closest to the epicentre and news of deaths emerged.

Some of the earliest footage of the aftermath of the quake appeared on Twitter soon after it struck late in the evening.

Twitter user Laween Qasim posted footage from the Kurdish city of Erbil in northern Iraq showing crowds of people who had gathered on a street after fleeing nearby buildings.

Erbil resident Omar Ali, the Iraq director for the British charity Human Appeal, described scenes in the city shortly after the tremors began.

"Just survived an earthquake. Building violently shaking. Ran from 19th floor. Many tears here. Thank God, alive and out safely!" he wrote on Twitter, describing how he came across an elderly woman inside his apartment block who pleaded with him for help.

Just survived an earthquake. Building violently shaking. Ran from 19th floor. Many tears here. Thank God, alive and out safely! #Erbil #Kurdistan #Iraq pic.twitter.com/2G5HYZ2LJz — Omar (@omaralikr) November 12, 2017

"Incredibly scary tbh (to be honest) from the 19th floor. Ran down with an old Iraqi lady ... she said don't leave me. First proper #earthquake experience."

Within hours, Ali, a British Palestinian, was back to work helping Human Appeal organise its response to the earthquake.

In neighbouring Iran, images emerged of greater devastation with rubble strewing the streets and buildings visibly damaged by the disaster.

A Twitter user named Ibrahim posted images sent to him by a relative showing the devastation in Kermanshah province, on the border with Iraq.

"People in Qasri Shirin have been buried under after the earthquake!! Electricity is gone people are outside in panic, trying to find their families," he wrote.

As the scale of the damage became clear, attention shifted to helping those in need. Some Twitter users queried what they could do, while others shared images of the outpouring of help people in Iran and Iraq were offering.

Iranian citizens in Tehran lining up to donate blood for those who wounded in last night earthquake, west of the country. pic.twitter.com/swpaqK2Aj6 — Alireza Karimi (@AlirezaKarimi12) November 13, 2017

One user, Alireza Karimi, posted pictures of Iranians in the capital, Tehran, who had gathered outside clinics where they hoped to donate blood to help treat those injured.

Iran is vulnerable to earthquakes because it is situated at the meeting of the Eurasian, Indian and Arabian tectonic plates.

In 2003, an earthquake in the southeastern town of Bam, killed at least 26,000 people, injured tens of thousands more, and flattened its historic citadel.