Egyptians in Cairo walk beneath a poster of President Abdel Fatah al-Sissi. The leader has struggled to wipe out the Islamic State. (Khaled Elfiqi/EPA-EFE/Shutterstock)

Unmarked Israeli warplanes and helicopters have carried out dozens of covert attacks against the Islamic State and other terrorist groups inside the Egyptian Sinai in recent years, said two former senior U.S. officials.

The airstrikes by Israeli planes are conducted with the support of President Abdel Fatah al-Sissi, who has led an often brutal campaign inside Egypt to wipe out the Islamist militant groups but has struggled to defeat them.

In November, the Egyptian affiliate of the Islamic State launched a brazen attack in which nearly 40 gunmen stormed the al-Rawdah mosque in Egypt’s sparsely populated Sinai, killing more than 300 worshipers.

The terrorist group, which consists of more than 1,000 members, first came to widespread public attention for its suspected role in the downing of a Russian airliner in 2015, in which 224 people were killed. Egypt’s military has struggled for years to destroy the group, which briefly seized control of the northern Sinai town of Sheikh Zuweid and has launched dozens of attacks on soldiers, police and Coptic Christian churches.

The covert alliance between Egypt and Israel on counter­terrorism shows how the rise of the Islamic State and other Islamist militant groups has helped forge quiet partnerships between Israel and its longtime Arab adversaries.

Israeli security officials say that their regional security concerns increasingly align with those of the Persian Gulf states. In 2016, Defense Minister Moshe Yaalon said Israeli officials were secretly meeting with counterparts from the gulf in “closed rooms” united against a common “bad guy” — Iran.

A former U.S. official described the covert counterterrorism alliance between Israel and Egypt as a “big deal” but said that in recent years, counterterrorism relationships have become “a little bit insulated from ups and downs” of the region’s tumultuous politics.

“The public perception of those two countries and how they relate is not in sync with how they work together privately on counter­terrorism,” said the former official, who was granted anonymity to discuss the sensitive alliance.

Another former U.S. official said the cooperation underscores how ineffective the Egyptians have been in combating militants on their own soil.

“It’s a symptom of how close the two countries have become in security cooperation,” said the former official who worked on issues in the region. “But it illustrates how poorly the Egyptians have done dealing with the terrorist threat. Both Israel and the United States have complained about the fact the Egyptians have not taken advice and recommendations the United States have been offering for some time.”

The official also said news of the cooperation, which he called one of the least well-kept secrets in the Middle East, is unlikely to have repercussions among ordinary Egyptians.

“ISIS has done so many horrible things in Egypt,” the official said, using another name for the Islamic State. “I’m not sure the average Egyptian will be more upset about who’s cooperating with who, than who’s the target of the cooperation.”

The Israeli counterterrorism strikes in northern Sinai were first reported by the New York Times. An Israeli military spokesman declined to comment on the alliance or confirm the existence of Israeli military operations inside Egypt.

Although there was an awareness of the strikes within the U.S. government, the former official said, the United States did not play a significant coordinating or supporting role. The official described the cooperation between Egypt and Israel as “organic.”

The Israeli aircraft operating in Egypt are unmarked and fly circuitous routes so it does not appear as if they are flying from Israel, reflecting the sensitivity of the program, according to the Times’ report.

On Twitter, Israeli journalists hinted that they had been unable to report the story because of censorship restrictions. Israeli journalists are required to submit articles related to matters of national security to a military censor before publication, with regulation also covering social media posts.

Egypt, Israel and Hamas broadly began to tighten security cooperation two years ago, forming an unlikely alliance as the Islamic State’s offshoot in Sinai began to stage more sophisticated, sustained attacks.

Under pressure from Egypt, Hamas has tightened its border with Sinai amid concerns in Cairo that Gaza could be used by Islamic State members as a staging ground. The Islamic State has lost much of its self-declared caliphate in Iraq and Syria over the past three years but remains a threat. Some U.S. counterterrorism experts warn that the group could step up terrorist attacks to prove its relevance, despite the collapse of its armies in Iraq and the loss of Raqqa, its capital in Syria.

U.S. officials have been carefully monitoring some of the group’s more significant affiliates, such as the branch in Sinai, to see how they may be affected by the broader collapse of the core group.

Loveday Morris in Jerusalem and Carol Morello in Washington contributed to this report.