Clashes between the Egyptian army and an armed group in Qalyubia province have killed a brigadier general and a colonel, according to the country's interior ministry.
The exchange of gunfire erupted on Wednesday after the army officers tried to storm a safe house belonging to self-declared jihadist group, Ansar Beit al-Makdis, in the Nile Delta region, north of Cairo.
At least five members of the armed group have been killed, the ministry said.
The group has claimed responsibility for some of the deadliest attacks. More than 200 policemen and soldiers since the army overthrew Islamist president Mohamed Morsi in July.
Most of the attacks have taken place in the Sinai Peninsula, where self-declared jihadist leaders are believed to be based.
The officers killed in the latest raid were bomb disposal experts who participated in the operation alongside police, the military said.
It said "a large quantity of explosives" was found in the hideout, with the interior ministry saying fighters had used explosive belts during the confrontation.
The hideout near the Nile Delta town Al-Qanatir Al-Khayriya, about 30km away from Cairo, was used to make explosives, the interior ministry said.
Attacks on security forces have spread to the capital and elsewhere in the Nile Delta.
On Saturday, gunmen shot dead six soldiers at a military checkpoint in northern Cairo and planted bombs to target first responders before fleeing the scene. The bombs were safely defused.