President Mohamed Morsi called an emergency meeting with the Supreme Council of the Armed Forces following the attack, the state broadcaster reported.
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 15 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 Gaza Strip "until further notice."
In Israel, military spokeswoman Lieutenant Colonel Avital Leibovich told reporters gunmen had hijacked two vehicles from an Egyptian outpost where they had 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, and the Israeli military was searching for any remaining gunmen, she said.
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 that 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 had been ordered to stay inside their homes until further notice, she added.
There were no Israeli civilians or soldiers wounded in the incident.
In a statement, 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 in a statement: "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 cited 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."
Sinai-based Islamist militants are believed to have been responsible for several rocket attacks against Israel.
Israel has 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 Hosni Mubarak, are based.
On July 19, gunmen believed to be Islamist militants shot dead two Egyptian soldiers in a dawn attack in north Sinai.
The attack came after Islamist militants distributed pamphlets calling on the army to leave the lawless north of the peninsula, where they had been brought in to restore security.
The attack was in Sheikh Zuwaid, a town roughly 15 kilometres (nine miles) west of the Islamist-ruled Gaza Strip.
The military sent tanks and soldiers into the region last year to quell Islamist militants, after receiving permission from Israel. Under a 1979 peace treaty with Israel, Egypt should have a limited military presence in the area.
COMMENTS (2)
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ
Mohammad Morsi should reach out to the Bedouins in the Sinai, who have felt discriminated under Mubarak's regime. They fought and drove out the army, which was sent to the restive region to restore law and order. If Morsi wants to regain control over the Sinai, he will have to renegotiate the peace treaty of 1979 with Israel. Yet the Israelis might not be happy, as they fear Cairo would scrap the whole treaty all together.
Jihadis have created problems all over the world and due to their violent behaviour, the image of Muslims has gone down quite a bit.