CAIRO (NYTIMES, AFP) - The militants in Egypt's Northern Sinai had killed hundreds of soldiers and police officers, pledged allegiance to the Islamic State in Iraq and Syria (ISIS), briefly seized a major town and begun setting up armed checkpoints to claim territory.
In late 2015, they brought down a Russian passenger jet.
Egypt appeared unable to stop them, so Israel, alarmed at the threat just over the border, took action.
For more than two years, unmarked Israeli drones, helicopters and jets have carried out a covert air campaign, conducting more than 100 airstrikes inside Egypt, frequently more than once a week - and all with the approval of President Abdel-Fattah el-Sissi, the New York Times reported.
The remarkable cooperation marks a new stage in the evolution of their singularly fraught relationship. Once enemies in three wars, then antagonists in an uneasy peace, Egypt and Israel are now secret allies in a covert war against a common foe.
For Cairo, the Israeli intervention has helped the Egyptian military regain its footing in its nearly five-year battle against the militants. For Israel, the strikes have bolstered the security of its borders and the stability of its neighbour.
Their collaboration in the North Sinai is the most dramatic evidence yet of a quiet reconfiguration of the politics of the region. Shared enemies such as ISIS, Iran and political Islam have quietly brought the leaders of several Arab states into growing alignment with Israel, even as their officials and news media continue to vilify the Jewish state in public.
US officials say Israel's air campaign has played a decisive role in enabling the Egyptian armed forces to gain an upper hand against the militants. But the Israeli role is having some unexpected consequences for the region, including on Middle East peace negotiations, in part by convincing senior Israeli officials that Egypt is now dependent on them even to control its own territory.
Seven current or former British and US officials involved in Middle East policy described the Israeli attacks inside Egypt, all speaking on the condition of anonymity to discuss classified information.
Spokesmen for the Israeli and Egyptian militaries declined to comment, and so did a spokesman for the Egyptian foreign ministry.
Israeli Prime Minister Benjamin Netanyahu said on Sunday (Feb 4) Israel would “do whatever is necessary to defend ourselves”, without directly addressing the New York Times report published on Saturday that its military has carried out dozens of air strikes against Islamists in Sinai.
Speaking at the start of a Cabinet meeting, Mr Netanyahu referred to recent meetings with US President Donald Trump, European leaders and Russian President Vladimir Putin.
“As I also made it clear to President Trump and afterwards to European leaders and President Putin, our presence here is the main element in the Middle East blocking the spread of radical Islam, led by Iran and Islamic State, which also threaten all other elements in the world,” he said.
“We are not bent on war, but we will do whatever is necessary to defend ourselves.”
Israel and Egypt have sought to conceal Israel's role in the airstrikes for fear of a backlash inside Egypt, where government officials and the state-controlled media continue to discuss Israel as a nemesis and pledge fidelity to the Palestinian cause, according to the New York Times.
The Israeli drones are unmarked, and the Israeli jets and helicopters cover up their markings. Some fly circuitous routes to create the impression that they are based in the Egyptian mainland, according to US officials briefed on their operations.
In Israel, military censors restrict public reports of the airstrikes. It is unclear if any Israeli troops or special forces have set foot inside Egyptian borders, which would increase the risk of exposure.
President El-Sissi has taken even more care, US officials say, to hide the origin of the strikes from all but a limited circle of military and intelligence officers. The Egyptian government has declared the North Sinai a closed military zone, barring journalists from gathering information there.
Behind the scenes, Egypt's top generals have grown steadily closer to their Israeli counterparts since the signing of the Camp David accords 40 years ago, in 1978. Egyptian security forces have helped Israel enforce restrictions on the flow of goods in and out of the Gaza Strip, the Palestinian territory bordering Egypt controlled by the militant group Hamas. And Egyptian and Israeli intelligence agencies have long shared information about militants on both sides of the border.
Israeli officials were concerned in 2012 when Egypt, after its Arab Spring revolt, elected a leader of the Muslim Brotherhood to the presidency. The new president, Mr Mohammed Morsi, pledged to respect the Camp David agreements. But the Israelis worried about the Muslim Brotherhood's ideological kinship with Hamas and its historic hostility to the Jewish state itself.
A year later, President el-Sissi, then the defence minister, ousted Mr Morsi in a military takeover. Israel welcomed the change in government, and urged Washington to accept it. That solidified the partnership between the generals on both sides of the border.
The North Sinai, a loosely governed region of mountainous desert between the Suez Canal and the Israeli border, became a refuge for Islamist militants in the decade before Mr el-Sissi took power. The main militant organisation, Ansar Beit al Maqdis - the Partisans of Jerusalem - had concentrated on attacking Israel, but after Mr el-Sissi's takeover it began leading a wave of deadly assaults against Egyptian security forces.
In November 2014, Ansar Beit al Maqdis formally declared itself the Sinai province branch of the ISIS. On July 1, 2015, the militants briefly captured control of a North Sinai town, Sheikh Zuwaid, and retreated only after Egyptian jets and helicopters struck the town, state news agencies said. Then, at the end of October, the militants brought down the Russian charter jet, killing all 224 people on board.
It was around the time of those ominous milestones, in late 2015, that Israel began its wave of airstrikes, the US officials said, which they credit with killing a long roster of militant leaders.
Though equally brutal successors often stepped in to replace them, the militants appeared to adopt less ambitious goals. They no longer dared trying to close roads, set up checkpoints or claim territory. They moved into hitting softer targets like Christians in Sinai, churches in the Nile Valley or other Muslims they view as heretics. In November last year, the militants killed 311 worshippers at a Sufi mosque in the North Sinai.
By then, US officials say, the Israelis were complaining to Washington that the Egyptians were not holding up their end of the arrangement. Cairo, they said, had failed to follow the airstrikes with coordinated movements of its ground troops.
Although Israeli military censors have prevented the news media there from reporting on the strikes, some news outlets have circumvented the censorship by citing a 2016 Bloomberg News report, in which an unnamed former Israeli official said there had been Israeli drone strikes inside of Egypt.
Mr Zack Gold, a researcher specialising in the North Sinai who has worked in Israel, compared the airstrikes to Israel's nuclear weapons programme - also an open secret.
"The Israeli strikes inside of Egypt are almost at the same level," he said. "Every time anyone says anything about the nuclear programme, they have to jokingly add 'according to the foreign press'. Israel's main strategic interest in Egypt is stability, and they believe that open disclosure would threaten that stability."