At least 23 Egyptian soldiers have been killed and 26 wounded in an attack by jihadist militants in the northern Sinai peninsula, security sources say.
A suicide car bomber reportedly targeted a checkpoint outside Rafah, a border town near the Gaza Strip, before dozens of gunmen opened fire.
The military said 40 assailants were killed in the ensuing clashes.
So-called Islamic State claimed the attack. The group is leading an insurgency in the region.
Hundreds of soldiers and police have been killed by militants affiliated to the jihadist group since 2013, when the military overthrew President Mohammed Morsi.
IS has also killed dozens of people in attacks targeting Egypt's Coptic Christian minority elsewhere in the country, and claimed it planted the bomb that brought down a plane carrying tourists in Sinai in 2015, killing 224 people on board.
Security officials told the Associated Press that Friday's attack targeted a military compound in al-Barth, south-west of Rafah, where about 60 soldiers were based.
First, a suicide bomber rammed his vehicle into a nearby checkpoint, the officials said. Then dozens of militants then arrived in 4x4 vehicles and fired machine-guns at the soldiers for about 30 minutes before fleeing the scene, the officials added.
The military said in a statement that a total of 26 soldiers were killed or injured in the attack, but did not provide a breakdown of the figure. It also posted photographs of five alleged assailants dressed in uniforms.
In a separate incident on Friday, two gunmen shot dead a senior officer from the police's National Security service as he left his home in the town of al-Jabal al-Safar in the north of the capital Cairo, according to the interior ministry.