EL-ARISH, Egypt (AP) -- Egypt vowed Monday to take on Islamist militants who have turned the Sinai peninsula into a lawless haven and are suspected of killing 16 Egyptian troops as the fighters were en route to a failed assault on neighboring Israel.

But the goal of reining in jihadists in Sinai is complicated by limits on military activity in the area under the 1979 peace treaty with Israel and by tensions between Egypt's Islamist President Mohammed Morsi and the country's powerful military.

"The armed forces have been careful in the past months and during the events of the revolution not to shed Egyptian blood," said a statement by the military. "But the group that staged this attack is considered by the armed forces as enemies of the nation who must be dealt with by force."

Morsi, who is enmeshed in a power struggle with the military leadership, pledged he would make the killers pay for their crime and would restore security to Sinai, home to several of the most popular Red Sea resorts in Egypt.

U.S. Defense Secretary Leon Panetta, who visited Egypt last week and met with its new leaders, said the U.S. had concerns about security threats in Sinai. Egypt has seen a sharp deterioration in security throughout the country since the uprising that ousted Hosni Mubarak in February 2011 and drove the hated police force from the streets. But even before the uprising, there was rampant lawlessness in Sinai.

The security problems stem from resentment among the native Bedouins over what they see as the police heavy-handedness and the lack of adequate government services. Security officials there say Islamists have forged alliances with disgruntled Bedouins.

Some Sinai Bedouins make a living out of growing illicit drugs, trafficking in black African migrants seeking a better life in Israel or supplying Gaza's merchants with goods through a network of secret tunnels running under the Egypt-Gaza border. A massive flow of smuggled arms from Libya, including heavy machine guns, RPGs and anti-aircraft guns, are making their way into the hands of militant groups operating in Sinai.

Like Egypt's enormous economic, social and political problems, the security crisis has been left to fester over the last 18 months while the military rulers who took power from Mubarak faced off against Islamists led by the Muslim Brotherhood who won both parliamentary and presidential elections in the transition period.

Adding to the complexities of escalating violence in Sinai are Egypt's fluctuating ties with the Islamist-ruled Gaza Strip, which also borders the peninsula. Mubarak, who repressed the Muslim Brotherhood, helped Israel enforce a blockade on Gaza. But Morsi and the Brotherhood have warmed ties with the Palestinian territory.

The Egyptian military claimed the attackers had the help of Palestinian militants, saying "elements from the Gaza Strip" aided them by shelling the Egyptian-Israeli border crossing with mortars as the attack was taking place.

Sunday's attack was the deadliest on Egyptian soldiers since the country's last war with Israel nearly 40 years ago.

Egypt's military said 35 militants were involved in the ambush. They opened fire with assault rifles and rocket propelled grenades on soldiers at a border checkpoint as they broke their daily fast for the holy month of Ramadan with a sunset meal.

They then commandeered at least one armored vehicle from the post and drove about 10 kilometers (6 miles) north and crashed through a security fence at the border crossing known in Israel as Kerem Shalom and in Arabic as Karam Abu Salem. The crossing at the northeastern tip of Sinai is the meeting point between Egypt, Gaza and Israel.

Chief Israeli military spokesman Brig. Gen. Yoav Mordechai told Army Radio that the militants seized a truck and an armored car, then blew up one of the vehicles to punch a hole through the security fence to enter Israel. He said that Israeli intelligence services had reports of impending infiltration and sent aircraft to strike as the militants broke through.

"We were prepared for it, so there was a hit," he said. The military "averted a major attack on southern Israel," he added.

Israel immediately detected the infiltration and launched an airstrike that Egypt said killed six militants. Egyptian officials said late Monday that Israel had handed back to Egypt the bodies of six militants killed and the burned out shell of the armored vehicle.

Israeli Prime Minister Benjamin Netanyahu visited the site where the militants broke through the border and expressed regret for the loss of the Egyptian lives.

"Israel and Egypt clearly have a shared interest in maintaining a quiet border," Netanyahu said.

Egyptian security and military officials said a pair of attack helicopters arrived in the Sinai town of El-Arish, about 30 miles west of the attack site, to aid the hunt for the militants and counter-terrorism forces poured into the area. Joint police and army patrols were combing the area on looking for militants while aircraft flew above.

The 1979 Egypt-Israel peace treaty restricts the number of troops and the type of weapons Egypt can deploy in Sinai, something that many in Egypt have been calling to revise since Mubarak's ouster. Israel has agreed in the past to Egypt sending reinforcements to bolster its forces there, but Egyptian officials did not say whether Israel had signed off on the helicopter deployment.

Morsi flew to the area for a firsthand look and to oversee plans to eradicate militants. He was accompanied by his defense minister, Field Marshal Hussein Tantawi, who headed the ruling military council that was in power since Mubarak's ouster up until the end of June.

However Morsi's hands are strongly tied when it comes to security policy. Before the military handed over power, it sharply curtailed the president's power and insisted on retaining control of all internal security matters and the defense ministry. Morsi and his Muslim Brotherhood are fighting the power grab.

The unrest there poses many daunting challenges for Morsi, who since coming to office on June 30 has warmed up to Gaza's Hamas rulers. Hamas officials condemned the killings of the soldiers. But Morsi may still come under pressure to back down from plans to end Egypt's cooperation with the Israeli blockade of Gaza.

Like Hamas, Morsi belongs to the Muslim Brotherhood, a fundamentalist Islamist group founded in Egypt in 1928 with supporters across much of the Arab world, including Gaza. Seeking to reverse his predecessor's hardline policy toward Hamas, Morsi has promised to ease the hardship endured by Gaza's 1.6 million residents as a result of years of siege by Mubarak's Egypt and his Israeli allies.

He has promised to open the Rafah border crossing -- Gazans' only gateway to the outside world -- round the clock and allow goods to move to and out of the coastal territory. With their shared enmity for Israel, Morsi and Gaza's rulers had appeared ready to strike an enduring alliance that could only have alarmed many in an Israel already concerned by the rise of Islamists in Egypt.

But the attack and the Egyptian military's assertion of Palestinian involvement may already have undermined that prospect. If Morsi maintains close ties with Hamas now, he could come under criticism for prioritizing the Brotherhood's agenda over the nation's interests.

Egypt-Israel relations have always been cool but since Mubarak was overthrown and Islamists rose to power, Israeli officials have expressed concern that ties would further deteriorate.

Immediately after the attack, however, Egypt shut the Rafah crossing with Gaza, an ominous sign for Gazans barred from entering Israel.

Gaza officials sent mixed signals over whether residents of the territory may have been involved. Gaza's deputy prime minister, Mohammed Awad of Hamas, said militants from the territory were "not involved in this awful crime." But a leading Hamas member, Mohammed Zahar, told Al-Jazeera TV that he asked Egypt to provide the names of possible suspects from Gaza so that "we will immediately bring them to justice."


Teibel reported from Jerusalem. Associated Press reporter Ibrahim Barzak in Gaza contributed to this report.