By Ahmed Mohamed Hassan and Yusri Mohamed
CAIRO/ISMAILIA, Egypt (Reuters) - At least 23 Egyptian soldiers were killed when suicide car bombs tore through two military checkpoints in North Sinai on Friday, security sources said, an attack claimed by Islamic State that marks one of the bloodiest assaults on security forces in years.
Islamic State militants are waging an insurgency in the rugged, thinly populated Sinai Peninsula. They have killed hundreds of soldiers and police since 2013, when the military ousted Islamist President Mohamed Mursi after mass protests against his rule.
- PHOTOS: It was a stylish No Pants Subway Ride 2019 in NYC19 Pictures
- All of these celebrities have had their nudes leaked 36 Pictures
The two cars blew up at two checkpoints outside of a military compound just south of Rafah, on the border with the Gaza Strip, the security sources said.
In a statement Islamic State said its fighters targeted the compound because the military was preparing to launch operations against the Sunni Muslim militant group from there.
The security sources said another 26 soldiers were injured in Friday's attacks. The military put the casualties lower, saying the attacks had killed and injured a total of 26 soldiers, without providing a breakdown of the figure.
The attack is the most severe in Sinai since at least July 2015, when Islamic State militants assaulted simultaneously a slew of checkpoints and military sites around North Sinai. At least 17 soldiers were killed, according to an official tally.
Friday's bombings present a challenge for general-turned-president Abdel Fattah al-Sisi, who describes Islamist militancy as an existential threat and himself as a bulwark against extremism in a region beset by violence and war.
Security sources described Friday's attack as a coordinated strike, with car bombs blowing apart checkpoints as gunmen in four-wheel drive vehicles shot down soldiers running for cover.
Militants in armored vehicles meanwhile fired rocket propelled grenades at a military site just beyond the checkpoint, the sources said.
The military carried out a counter-attack almost immediately after, deploying fighter jets to kill over 40 militants suspected of involvement and destroying six of their vehicles, according to a video released by the military showing aerial footage of air strikes.
The military posted photos of five dead militants in blood-soaked fatigues lying in the sand. It did not name their affiliation.
"Law enforcement forces in North Sinai succeeded in thwarting a terrorist attack on some checkpoints south of Rafah," a military statement said.
The bloody assault comes as militant attacks have increasingly shifted beyond the Sinai deep into Egypt's heartland, often targeting minority Coptic Christians.
Separately on Friday, a homeland security officer was shot dead outside his home in Qalubiya, a province just north of Cairo, while on his way to Friday prayers, an Interior Ministry statement said.
That attack was later claimed by the Hasam Movement, a militant group that has claimed several attacks around Cairo targeting judges and policemen since last year.
Responding to the Sinai attack, Prime Minister Sherif Ismail stressed the need for countries to unite against those who support terrorism and to "dry up their sources of funding," an allusion to Qatar.
Egypt, Saudi Arabia, the United Arab Emirates and Bahrain broke diplomatic relations with Qatar last month and are now boycotting the Gulf Arab state, which they accuse of supporting terrorism and allying with regional foe Iran. Qatar denies this.
(Reporting by Ahmed Mohamed Hassan and Yusri Mohamed in Ismailia; Additional reporting by Omar Fahmy, Ali Abdelaty, and Ahmed Tolba in Cairo; Writing by Eric Knecht; Editing by Larry King and Chris Reese)