At least 141 people were killed in Iran, Behnam Saeedi, a spokesman for Iran's National Disaster Management Organisation, said on the state television. More than 850 were injured, he said.
The earthquake was felt in several provinces of Iran but the hardest hit province was Kermanshah, which announced three days of mourning.
More than 97 of the victims were in the town of Sarpol-e Zahab in Kermanshah, about 15 km (10 miles) from the Iraq border. The main hospital of the town was severely damaged and struggling to treat hundreds of injured people, state television reported.
Kurdish health officials also said at least four people were killed in Iraq and at least 50 injured.
The U.S. Geological Survey said the quake measured magnitude 7.3. An Iraqi meteorology official put its magnitude at 6.5 with the epicentre in Penjwin in Sulaimaniyah province in the Kurdistan region close to the main border crossing with Iran.
Electricity was cut off in several Iranian and Iraqi cities, and fears of aftershocks sent thousands of people in both countries out onto the streets and parks in cold weather.
Many houses in rural parts of the province are made of mud bricks and are known to crumble easily in quake-prone Iran.
A quake registering a magnitude between 7 and 7.9 can inflict widespread and heavy damage.