The incident in the volatile Diyala province underlines the unrelenting dangers that members of Iraq's security forces still face as American forces prepare to reduce their numbers by the end of the month and end all combat operations.
The incident occurred about 1 a.m. in the town of Sadiyah, 60 miles (95 kilometers) north of Baghdad, when a gunman opened fire on soldiers from a house near an Iraqi army checkpoint, the officials said.
The soldiers called in support and surrounded the house. The house then blew up, killing the eight soldiers and wounding another four.
The death toll was confirmed an Iraqi police official in the province and Capt. Qais Ahmed, from the Iraqi army in Sadiyah.
Meanwhile in Baghdad, gunmen broke into the house of a senior female doctor and killed her, Iraq's health minister and a police official said.
The minister, Saleh al-Hasnawi, said the gunmen broke into the house of Dr. Intissar al-Tuwaijri at about 6:00 a.m., tied up her husband and killed her.
Al-Hasnawi said he believed the killing of the physician he described as one of the best doctors in the country was a criminal incident, and that his ministry was waiting for the results of a police investigation.
Al-Tuwaijri was the general director of Alwiyah Maternity hospital in Baghdad's central Karradah area.
A police officer said the preliminary investigation showed that the gunmen used pistols fitted with silencers and stole 250 million Iraqi dinars (about $215,000).
All the officials spoke on condition of anonymity because they were not authorized to release information.
Associated Press Writer Yahya Barzanji in Sulamaniyah, Iraq, contributed to this report.