A bomb fell from an Iraqi Sukhoi warplane and exploded in eastern Baghdad on Monday because of a "technical problem", killing at least eight people and wounding 17, officials said.
"One of the bombs became stuck because of a technical problem, and during its (the aircraft's) return to base it fell on... houses in Baghdad Jadida," security spokesman Brigadier General Saad Maan said.
The pilot tried six times to drop the bomb, which became stuck while he was carrying out strikes against the Islamic State (IS) jihadist group, but was unable to dislodge it "mechanically or manually," the defence ministry said in a statement.
But the bomb came loose as the plane overflew Baghdad to land at its base, the ministry said.
The governor of Baghdad province, Ali al-Tamimi, called for the Rasheed air base, where the plane was bound, to be moved to a non-residential area.
Tamimi said he contacted the air force and was told the plane was returning from the Haditha area in Anbar province, which is surrounded by IS.
The explosion ripped through small houses in Baghdad Jadida, tearing down walls, smashing roofs and leaving bricks and other rubble piled in the street.
Signup to our newsletter and follow us on Facebook and Twitter!
"Our house was destroyed," said Ali Jassem, a 27-year-old interior ministry employee.
Jassem said that if an accidental bombing can happen in an area where there is no fighting, "God knows the extent of the events happening" in combat zones.
Iraq received Sukhoi Su-25 jets from Russia and Iran last year as it sought to bolster its fledgling air force to combat IS, which overran large parts of the country.
The Su-25s are robust aircraft designed for ground attack missions, but Iraq's Sukhoi fleet is made up of ageing planes that have seen heavy use as Baghdad's forces battle to push the jihadists back.
The US agreed to sell Baghdad 36 F-16 warplanes, but none have been delivered to Iraq so far.
The first batch of the jets has instead been sent to Arizona, where Iraqi F-16 pilots are training.
One of the pilots, Brigadier Rasid Mohammed Sadiq, was killed in a crash during an aerial refuelling exercise at the end of June.