Hamas forces deploy on the Palestinian side of the border with Egypt in southern Gaza on April 21. (Khalil Hamra/AP)

The Islamic State’s affiliate in Egypt is staging increasingly sophisticated and daring attacks, officials and analysts say, prompting Israel, Egypt and the Palestinian militant group Hamas to form an unlikely alliance against the terrorist group.

Hamas deployed several hundred fighters last week to Gaza’s border with Egypt’s lawless northern Sinai as part of a deal with Egypt to keep militants of the Islamic State — also known as ISIS or ISIL — from entering the coastal enclave.

That came days after Israeli Prime Minister Benjamin Netanyahu praised his country’s decision to build a new barrier along the Israel-Egypt border, warning that “we would have been overflowed by thousands of ISIS fighters from Sinai.”

The growing concerns have given birth to the greatest cooperation between the militaries of Egypt and Israel since their 1979 peace deal, according to officials from both countries.

The question is whether the militants’ ambitions can be stopped or, at least, contained.

The well-armed affiliate — known as Wilayat Sinai — has grown bolder since it asserted responsibility for the October bombing of a Russian charter flight over the Sinai Peninsula, killing all 224 aboard. The group has mounted a steady stream of attacks on Egyptian soldiers, overrunning military posts and targeting them with roadside bombs.

In the April issue of an Islamic State newsletter, al-Naba, the terrorist group boasts about the attacks.

“Elements of the infidel Egyptian army were attacked today by the soldiers of the caliphate in a number of attacks all over Sinai,” the Islamic State declared, then went on to name six different assaults over several days, including one in the provincial capital, al-Arish.

Egyptian intelligence bodies have struggled to penetrate the sanctums of the secretive militants, said Israeli military officials and Egyptian activists and residents in the Sinai.

“They have genius strategists,” said Mohannad Sabry, an Egyptian journalist and author of a book on the Islamist insurgency in the Sinai. “If you study the map of their attacks, they obviously know what they are doing exactly, and it shows that they have a great deal of freedom of mobility.”

Egypt’s military-backed government publicly says it is winning the war in the Sinai. It routinely releases statements about militants it has captured or killed in raids. But those reports have been impossible to verify independently because journalists are prohibited from traveling to the northern Sinai.

Increasingly, though, Egypt’s Western allies are worried about the government’s ability to stem the expanding Islamic State activities. Last weekend, Gen. Joseph F. Dunford Jr., chairman of the Joint Chiefs of Staff, made his second trip to Egypt in two months to discuss the Sinai and regional security.

The United States and Israel are particularly concerned that the militants could threaten a multinational peacekeeping effort that has overseen the peace between Egypt and Israel along the Sinai border. Some member countries providing troops could be targeted for taking part in the broader operations against the Islamic State in Syria and Iraq.

The Multinational Force and Observers (MFO) includes roughly 700 American peacekeeping personnel. Four U.S. soldiers from the force were wounded by a roadside bomb last year, and the Pentagon has already moved some troops to the less restive southern Sinai.

In a recent tweet, the militants asserted responsibility for destroying an American-made Egyptian M60 tank near Gora airport, used by peacekeepers as a base.

On Friday, the group claimed to have cut off an Egyptian military supply route to the airport, triggering clashes after it attacked a convoy carrying food and arms.

“Like anywhere, they could be considered a potential target,” said Lt. Col. Yaron Malka, the deputy commander of Israel’s Saqi Brigade that defends Israel’s border with the Sinai, referring to the multinational peacekeepers.

On a recent day, Malka stood behind a blast wall atop a hill near the fenced border. Before him was the Sinai Peninsula, so close that his soldiers see — and often wave to — peacekeeping observers and their protective forces.

Malka swept his hand toward the horizon.

“ISIS is just out there,” he said.

Within a couple of miles of the Israeli military base, within easy range of a pair of field binoculars, fierce fighting between the militants and the Egyptian army has occurred regularly.

Eighteen months ago, the militants were under growing pressure as the Egyptian government arrested or killed their leaders in the Sinai and in the Nile Valley, in southern Egypt.

Then, in November 2014, they declared allegiance to the Islamic State, creating what they described as the latest “wilayat” or province of the terrorist group.

“ISIS was very wealthy and had money to spread around,” said Zack Gold, a scholar with the Atlantic Council, a think tank in Washington, who has been tracking the group. Establishing an Islamic State franchise in the Sinai, he added, “was a major pickup for them. In a stroke, they allied with the most active, most proficient, most deadly unaffiliated jihadists in the world.”

Today, the Islamic State in the Sinai has an operational core of hundreds of fighters, not thousands, analysts and military officials say. Unlike the Islamic State in Syria and Iraq, there are few, if any, foreign fighters. The Sinai militants do not hold any territory or stage large-scale offensives, preferring to work within small cells to carry out hit-and-run attacks. Their weapons include antitank ground missiles and rocket-propelled grenades, many of which were smuggled in from neighboring Libya in the aftermath of the 2011 revolution that toppled dictator Moammar Gaddafi.

The militants may be reluctant to strike the foreign peacekeeping mission because many tribal members work or contract with the multinational force, Gold said.

Still, resentment toward the Egyptian military’s tactics to combat the militancy is growing. Human rights groups and Sinai community leaders describe a scorched-earth policy of home destructions, forced evictions and arbitrary detentions against the local population.

“If people have been treated like traitors, don’t have jobs, have their homes destroyed, and cannot reach the outside world, and are constantly being attacked, then, of course, ISIS will recruit more people,” said one community leader from one of the Sinai’s largest tribes. He spoke on the condition of anonymity because he had been jailed for three years by the military.

Israeli and Egyptian officials have long suspected that Hamas, which rules the Gaza Strip, allows the Sinai militants to enter the enclave through smuggling tunnels and use the strip as a safe haven. Israelis say Hamas brings arms across the Sinai into Gaza and is helped by Bedouin smugglers, some tied to the Islamic State. Hamas denies the allegations, saying it has no sympathies to the Islamic State, which branded Hamas as infidels in a video two years ago.

But the concerns were enough for the Egyptians to apply pressure on Hamas to control its border and prevent any movement of fighters or couriers between Gaza and Sinai. Gaza depends on Egypt in part for its economic survival, and Hamas is keen to have its border with Egypt reopened.

A Hamas official this week said there are now more than 300 Hamas fighters deployed in three areas along the sea and two land border crossings with the Sinai.

“The national security forces redeployed along the borders with Egypt, and it is part of the security plan to fully control the borders and the stability of it, as well as the security of our Egyptian brothers,” Eyad al-Bozom, a Hamas Interior Ministry spokesman, said in a statement.

Even though they still consider the Islamic State threat to be minimal, the Israelis are concerned that it is just a matter of time before the militants turn their attention to the Jewish state. As he gazed across the wall into the expanse of the Sinai, Lt. Col. Malka wondered: “When will we become the target?”

Booth reported from Nitzana, Israel. Heba Habib in Cairo and Hazem Balousha in Gaza contributed to this report.

U.S. military chief pays a visit to Cairo as the Sinai militancy intensifies

Egypt’s upheaval has transformed much of the Sinai into a no-go zone

U.S.-led strikes putting a financial squeeze on the Islamic State

Today’s coverage from Post correspondents around the world