Gunmen killed 16 guards in Egypt near the border with Israel before stealing two armoured vehicles and crossing into the Jewish state where one vehicle was destroyed by a helicopter.
An Egyptian medical official said gunmen in Bedouin attire drove up in two vehicles and opened fire on a checkpoint near the Karm Abu Salem (Kerem Shalom in Hebrew) border crossing and opened fire.
The health ministry said 16 soldiers and border guards were killed, while a security official said another seven were wounded.
The official MENA news agency said the gunmen were "jihadists" from inside the Islamist Hamas-run Gaza Strip.
State television and MENA reported that Egypt was closing its Rafah frontier crossing with the Hamas-controlled Gaza Strip "until further notice".
Rafah is the only crossing between Gaza and the outside world that is not under Israeli control.
Speaking after an emergency meeting with military officials, the interior minister and the intelligence chief, Egyptian President Mohamed Morsi vowed to retake control of the Sinai after the attack.
"The (security) forces will take full control of these regions," Morsi said in a television address.
He had given "clear instructions" that Egypt must take "full control of the Sinai", after the security situation deteriorated markedly following the ouster of longtime strongman Hosni Mubarak early last year.
Morsi, who only took the oath of office on June 30 to become the country's first freely elected leader and its first head of state since Mubarak's overthrow, said those who committed the "cowardly" attack and those who worked with them would pay it dearly.
"Those responsible for this crime will be hunted down and arrested," he said.
"Everybody will see that the Egyptian military and police forces can get these criminals wherever they are," he said. "These criminals, these attackers do not belong among us."
In Israel, military spokeswoman Lieutenant Colonel Avital Leibovich told reporters gunmen hijacked two vehicles from an Egyptian outpost where they killed between 10 and 15 border guards before crossing the frontier.
One of the vehicles exploded by itself and the other was destroyed from the air, she said. Overnight Sunday the Israeli military was searching for any remaining gunmen.
She did not know how many had been on board the vehicles and if any had survived.
Israeli public radio said the vehicle had been targeted by a helicopter and that three "terrorists" on board had been killed.
Leibovich confirmed that the incident had taken place in the Kerem Shalom area.
"A few of the people who manned the vehicles started running away. We targeted them," she said.
Residents of the nearby Israeli communities were ordered to stay inside their homes until further notice, she added.
No Israeli civilians or soldiers were wounded in the incident.
Israeli Prime Minister Benjamin Netanyahu hailed "the determined action of the military" and domestic intelligence agency Shin Bet "for ensuring the failure of a large attack on Israeli civilians".
Defence Minister Ehud Barak said: "The way these attackers acted again shows the need for the Egyptian authorities to act firmly to re-establish security and fight terrorism in the Sinai."
Leibovich said it was too early to determine the gunmen's affiliation or what they were trying to do, but "one of the assumptions is they were trying to kidnap Israeli soldiers".
MENA however identified the gunmen as "jihadists" from the Islamist-run Gaza Strip.
"Jihadist elements infiltrated from Gaza through tunnels in collaboration with jihadist elements in the Al-Mahdiya and Gabal Halal areas" inside Egypt, the agency said.
They "attacked a border post while the soldiers and officers were taking iftar," the meal that breaks the Ramadan fast, it added, quoting an unidentified official.
Earlier Sunday, before MENA's report, Hamas in Gaza had dismissed the idea that militants from the Palestinian territory may have been involved.
"The border between Egypt and Gaza is protected. We closed the tunnels (used for smuggling) to prevent anyone from escaping (into Gaza) and we have put our forces on alert," an interior ministry spokesman said.
"We reject any idea that Gaza was involved in this incident and we send our condolences over the killing of Egyptian soldiers."
A Hamas statement said: "We condemn this ugly crime in which Egyptian soldiers were killed, and send our condolences to the families of the victims, and to the Egyptian leadership and the Egyptian people."
Witnesses confirmed to AFP that police had closed all tunnels and sent reinforcements to the border.
Sinai-based Islamist militants are believed to have been responsible for several rocket attacks against Israel.
Israel accused them of having carried out a cross-border ambush last year that killed nine Israelis, and they have also been blamed for regular bombings of a pipeline that exports gas to Israel and Jordan.
The Sinai is home to Egypt's Red Sea resorts, a source of lucrative tourist income, and is also where the country's Bedouin, long marginalised under the regime of fallen strongman Mubarak, are based.
To stop any attacks and illegal cross-border activities Israel has sped up construction of a wall fitted with an electronic alert system along its 240-kilometre (150-mile) border with Egypt.