At least 23 Egyptian soldiers were killed and dozens wounded when two suicide car bombers hit army checkpoints in northern Sinai on Friday, security sources said.
The two cars exploded as they passed through two checkpoints close to each other on a road outside the border city of Rafah, the sources said. No group claimed responsibility for the attacks.
The army said later security forces had killed 40 militants and destroyed six of their vehicles following the attack.
"Law enforcement forces in northern Sinai succeeded in thwarting a terrorist attack on some checkpoints south of Rafah," the army statement said.
The army posted photos of five dead militants in blood-soaked fatigues lying in the sand, though it did not identify which militant group it believed the men belonged to.
Islamic State is leading an insurgency in the rugged and thinly populated northern Sinai desert, where hundreds of soldiers and police have been killed since 2013, when the army ousted Islamist president Mohamed Mursi following mass protests.
The insurgents in Sinai pledged allegiance to Islamic State in 2014 and adopted the name Sinai Province.
President Abdel Fattah al-Sisi describes Islamist militancy as an existential threat to Egypt, which has increasingly seen attacks move beyond the Sinai Peninsula and deep into the mainland, often targeting Christians.
Want to enjoy 'Zen' reading - with no ads and just the article? Subscribe todaySubscribe now