Updated

At least 54 policemen, including 20 officers and 34 conscripts, were killed when a raid on a militant hideout southwest of Cairo escalated into an all-out firefight, authorities said Saturday, in one of the single deadliest attacks by militants against Egyptian security forces in recent years.

The officials said the exchange of fire began late Friday in the al-Wahat al-Bahriya area in Giza province, about 135 kilometers (84 miles) southwest of Cairo.

The firefight began when security forces acting on intelligence moved against a militants' hideout in the area. Backed by armored personnel carriers and led by senior counterterrorism officers, the police contingent drew fire and rocket-propelled grenades, according to the officials.

The officials said what happened next is not clear, but indications suggest that the force ran out of ammunition and that the militants captured several policemen and later killed them. One officer managed to escape in his armored vehicle, they added.

The officials said the police force appeared to have fallen into a carefully planned ambush set up by the militants. The death toll could increase, they added, speaking on condition of anonymity because they were not authorized to brief media.

Those killed included two police brigadier-generals, a colonel and 10 lieutenant colonels.

The last time Egypt's security forces suffered such a heavy loss of life was in July 2015 when militants from the extremist Islamic State group carried out a series of coordinated attacks, including suicide bombings, against army and police positions in the Sinai peninsula, killing at least 50. However, the army said only 17 soldiers and over 100 militants were killed.

An official statement issued Saturday said Friday's incident would be investigated, suggesting that the heavy death toll may have been partially caused by incompetence, intelligence failures or lack of coordination. The officials said prosecutors will look into whether the police's counterterrorism agents failed to inform the military of the operation or include them.

The heavy loss of life, moreover, will now likely lead to the restructuring and streamlining of the country's counterterrorism effort, with better coordination between the police, military and security agencies high on the list of objectives, said the officials.

Egypt's Interior Ministry, which is in charge of police, announced a much lower death toll, saying that 16 were killed in the shootout. It added that 15 militants were killed or injured.

An audio recording purportedly by a policeman who took part in the operation was circulated online late Friday. The policeman, apparently using a two-way radio, was heard in the nearly two-minute recording pleading for help from a higher-ranking officer. The authenticity of the recording could not be immediately verified.

"We are the only ones injured, sir," the policeman said. "We were 10 but three were killed. After their injury, they bled to death, sir."

"They took all the weapons and ammunition," he added, "We are now at the foot of a mountain."

No militant group immediately claimed responsibility for the attack, which bore all the hallmarks of the Islamic State group. A local affiliate of the extremist group is spearheading an insurgency whose epicenter is in the Sinai Peninsula, which borders Israel and the Gaza Strip.

Attacks by militants have significantly increased since the 2013 ouster by the military of an Islamist president, who was freely elected but whose one-year rule proved divisive. Attacks have also spread outside Sinai and into the country's mainland and areas close to the porous Libyan border to the west.

The country has been under a state of emergency since April, following a spate of suicide bombings targeting minority Christians that have killed more than a 100 since December. The attacks were claimed by ISIS.

Egypt blamed the attacks on the Christians on militant cells trained and armed in neighboring Libya, where mostly Islamist militias, including extremist groups like IS, control territory or maintain a foothold in the vast, oil rich nation. In response, Egypt has stepped up security along its desert border with Libya, where it supports an eastern-based army general fighting militant groups.

In July 2014, gunmen armed with rocket-propelled grenades attacked a border guard post in Egypt's western desert in a brazen assault that killed 21 troops deployed close to the Libyan border.