Egypt has declared an emergency after a co-ordinated assault on an army checkpoint in the Sinai Peninsula killed 30 troops in the deadliest single attack on the military in decades.
The government, struggling to stem a wave of violence by Islamic extremists since the overthrow of Islamist president Mohammed Morsi, described it as "well-planned" attack that began with a car bomb which may have been set off by a suicide attacker.
Other militants then fired rocket-propelled grenades, striking a tank carrying ammunition and igniting a secondary explosion. Roadside bombs intended to target rescuers struck two army vehicles, seriously wounding a senior officer.
State-run TV said clashes between troops and militants followed the bombing. The car bomb exploded at the checkpoint at around 3.30pm Cairo time about nine miles from the northern Sinai city of el-Arish, in an area called Karm el-Qawadees.
There was no immediate claim of responsibility but officials said the assault bore the hallmarks of the country's most active militant group, Ansar Beit al-Maqdis (Champions of Jerusalem), which has carried out a string of previous attacks on security forces.
The death toll is expected to rise because 28 people were wounded and several are in a critical condition.
Egypt's National Defence Council declared a three-month state of emergency in areas near borders with Israel and the Gaza Strip in the northern part of Sinai Peninsula and ordered a three-hour curfew from today. State TV also announced closure of the Rafah crossing, Gaza's only non-Israeli passage to the outside world.
Headed by Egypt's President Abdel-Fattah el-Sissi, the council vowed that the army would take "revenge for the shedding of dear blood". It instructed authorities to take measures which it described necessary to protect lives of civilians.
Mr El-Sissi, the former defence minister and army chief who overthrew Mr Morsi last year, has said in the past that the militants hide in populated areas, making it difficult for the military to combat them.
The United Nations Security Council condemned the attack and reiterated its determination to combat all forms of terrorism.
The Egyptian government is considering evicting people living in small northern Sinai villages that are considered the "most dangerous" militant bastions and declaring certain areas to be closed military zones.
TV presenters reporting the attack wore black and displayed a black ribbon at the top of the screen while patriotic songs played.
Egypt's official news agency MENA said military helicopters ferried the dead and wounded to Cairo hospitals. Egypt's top Islamic authority, Grand Mufti Shawki Allam, said those who carried out acts of terrorism "deserve God's wrath on Earth and at the end of days".
Islamic militants have been battling security forces in the Sinai for a decade, but the violence surged after the military overthrew Mr Morsi in July 2013 amid massive protests demanding his resignation. Suicide bombings and assassinations have also spread to other parts of Egypt, with militants targeting police in Cairo and the Nile Delta.
The government has blamed the violence on Mr Morsi's Muslim Brotherhood group and launched a sweeping crackdown against his supporters, killing hundreds in street clashes and jailing about 20,000 people. Authorities have tried to link the group to Ansar Beit al-Maqdis by airing confessions of people alleged to belong to both.
The Brotherhood officially renounced violence decades ago and has denied involvement in the recent attacks, saying it is committed to peaceful protests demanding Mr Morsi's reinstatement.
Ansar Beit al-Maqdis claimed responsibility for a car bomb attack on a security headquarters in the Nile Delta city of Mansoura that killed 16 people, almost all policemen, in December 2013. It also claimed the attempted assassination of Egypt's interior minister in September of that year.
Authorities say it was responsible for the killing of 25 policemen who were bound and blindfolded before being shot dead on a Sinai roadside in August 2013. The government also blamed the group for an attack on Egyptian troops patrolling the remote western border with Libya in July, which left 22 soldiers dead. No one claimed responsibility for either attack.
In January Ansar Beit al-Maqdis released a video of its fighters downing a military helicopter over Sinai with a shoulder-fired missile, an attack that killed all five crew members and raised concern over the group's growing military prowess.
The group was initially inspired by al Qaida, but in recent months it has expressed affinity with the al Qaida breakaway group that refers to itself as the Islamic State (IS), and which controls large parts of Syria and Iraq.
In January, the leader of Ansar Beit al-Maqdis, Abu Osama al-Masri, praised IS in a recording posted on jihadi forums and the group has also released videos of the beheading of men it accused of being informants.
Sinai-based militants have exploited long-held grievances in the impoverished north of the peninsula, where the mainly-Bedouin population has complained of neglect by Cairo authorities and where few have benefited from the famed tourist resorts in the more peaceful southern part of Sinai.
Police in northern Sinai largely fled during the 2011 uprising that toppled President Hosni Mubarak, as militants attacked stations and killed scores of security forces.
Egypt has a long history of Islamic militancy. Former president Anwar Sadat was assassinated in 1981 and extremists carried out a wave of attacks targeting security forces, Christians and Western tourists during the 1990s.