A suicide attack claimed by the Islamic State group killed two Iraqi generals on Thursday in the key battleground province of Anbar, as the jihadists made gains in neighbouring Syria.
IS overran large areas of Iraq in 2014 and seized Anbar capital Ramadi earlier this year. It also controls major territory in Syria, where it has thrived amid a bloody civil war.
Military spokesman Brigadier General Yahya Rasool said a suicide bomber in an explosives-rigged vehicle struck the Al-Jaraishi area north of Ramadi as Iraqi forces advanced.
The attack killed the deputy head of the Anbar Operations Command, Abdulrahman Abu Raghif, and 10th Division commander Safin Abdulmajid, said Rasool.
IS claimed responsibility for the attack in a statement online, but gave a different account of how it unfolded, saying it was carried out by four suicide bombers and two supporting gunmen who targeted the main command headquarters north of Ramadi.
It said all six of the jihadists were killed.
The Iraqi Joint Operations Command confirmed the deaths of the two officers along with an unspecified number of other "heroic martyrs".
The death or injury of senior officers during battles against IS is a persistent problem for Iraq.
Two heads of the Anbar Operations Command have been wounded this year, while the commanders of a division and a brigade were killed in Anbar in April. The province's governor was wounded in 2014.
Senior army and police commanders have also been killed in other provinces since IS launched its devastating offensive in June 2014, sweeping security forces aside.
IS advances in Syria
Baghdad's forces have managed to regain significant territory in two provinces north of the capital, but much of western Iraq, including Anbar, remains outside government control.
In Syria, IS seized five villages from rebel forces overnight in the northern province of Aleppo and deployed on three sides of a key opposition bastion there, said the Syrian Observatory for Human Rights.
A handout picture released by the Iraqi Prime Minister's office on August 27, 2015 shows Prime Minister Haider al-Abadi (C) and Defence Minister Khaled al-Obeidi (C-R) attending the funeral in Baghdad.
The jihadist group overran three villages near the town of Marea, cut the rebel bastion off from the north, east and south, and took two more villages further north in Aleppo province, it said.
Those two villages were previously controlled by Al-Nusra Front, Al-Qaeda's Syrian affiliate, which withdrew from them after Turkey and the United States announced plans to cooperate on an IS-free zone in the area.
Marea is one of the most significant rebel-held towns in northern Aleppo and lies on a key supply route running to the Turkish border.
IS has targeted it for months, seeking to expand westwards from territory it holds in Aleppo province.
The Observatory said there were reports of dozens of rebel casualties in the fighting, but it had no immediate toll, while at least 18 IS members were killed in the fighting for Marea and the five villages.
Mamoun al-Khatib, a journalist and activist from Marea, also said the town was cut off from three directions and said dozens of jihadists had been killed trying to storm it.
He said some 5,000 civilians were inside the town, which was under IS mortar fire on Thursday afternoon.
The IS advances come despite an agreement between Turkey and the United States to work on establishing the IS-free zone in northern Aleppo.
The plan has backing from some rebel forces on the ground, including the powerful Islamist Ahrar al-Sham movement, which Washington does not work with.
Iraqi Sunni volunteers from Anbar province, who joined Iraq's Popular Mobilisation in the fight against the Islamic State (IS), are seen at their graduation ceremony at the Habaniyah military base, near Ramadi, on June 17, 2015.
But Al-Nusra has rejected the proposal, despite its opposition to IS, and earlier this month withdrew from its front lines against its jihadist rival in Aleppo in order to avoid cooperating with the plan.
Elsewhere in Syria, the Observatory said a new 48-hour truce between regime forces and rebels entered into force in three towns on Thursday.
It follows a similar ceasefire this month for the towns that was intended to lead to a broad agreement to end the fighting in Zabadani and the blockade of Fuaa and Kafraya.
Pro-regime forces, including Lebanon's Shiite Hezbollah militia, launched an offensive to seize Zabadani from rebel groups early last month.
The town is the last rebel-held bastion in the area along the border with Lebanon and has been subjected to massive aerial bombardment since the operation began.
More than 240,000 people have been killed in Syria since the conflict began in March 2011 with peaceful anti-government protests.