Egyptian soldiers carry coffins of 16 Egyptian soldiers who were killed Aug. 5, 2012 during an attack by militants at a checkpoint along the Sinai border with Israel at a military funeral in Cairo on Aug. 7, 2012. (Amr Nabil/AP)

Egyptian President Mohamed Morsi did not attend the military funeral Tuesday for the 16 soldiers killed over the weekend in an attack by militants in the Sinai Peninsula, a conspicuous absence for a leader whose thorny relationship with the military is being closely watched.

Sunday’s attack near the Israeli border has presented Morsi with a potentially explosive crisis during the Islamist president’s first days in office. On Tuesday, angry Egyptians heckled and tried to assault Prime Minister Hesham Kandil when he arrived for prayers before the funeral, prompting his security detail to whisk him out.

Yasser Ali, the president’s spokesman, told state television that Morsi chose not to attend the funeral to allow mourners to gather without the kind of reinforced security his presence would have warranted. Morsi did, however, go to a military hospital to visit soldiers wounded in the attack and receive reports on their injuries, Ali added.

The turmoil at the funeral, as well as Morsi’s absence, raised questions about the competence of the newly installed government.

It reflects “confusion and chaos surrounding the transition,” said Shadi Hamid, an Egypt expert at the Brookings Doha Center, adding that many Egyptians are asking, “Who’s calling the shots, and who’s ultimately making the decisions?”

Kandil attempted to attend funeral prayers at Cairo’s al-Rashdan Mosque but was forced to leave soon after he came under attack, according to the English-language state-run news site Ahram Online. The prime minister was not hurt but did not attend the military funeral that followed the prayers at a nearby square.

Protesters pursued Kandil and his motorcade, waving shoes in the air and yelling slogans against the Muslim Brotherhood, the Islamist group that propelled Morsi to power.

Other leading Egyptian political figures attended the funeral, including military chief Field Marshal Mohammed Hussein Tantawi and former prime ministers Kamal el-Ganzouri and Essam Sharaf, according to Ahram Online.

The attack in northern Sinai occurred Sunday near Rafah, the site of a border crossing into the Gaza Strip, a Palestinian territory. It began at sundown as the Egyptian soldiers were breaking their daily fast for the holy month of Ramadan.

According to security officials, masked gunmen hijacked two armored personnel carriers and drove them toward the Egypt-Israel border. One of the vehicles exploded at a border crossing, and the other was destroyed by an Israeli military airplane after it entered Israeli territory.

Violence has escalated in Sinai since the Egyptian revolution, when police stations and checkpoints were attacked. In recent months, extremist Islamist militants have taken root in the peninsula, according to local Bedouin tribal leaders.

Egyptian officials say they are trying to identify the group or individuals who organized Sunday’s attack. No organization has claimed responsibility.

Prominent Egyptian politicians renewed calls this week for a reexamination of the 1979 U.S.-brokered peace treaty between Egypt and Israel, which limits Egypt’s military presence in Sinai.

Ingy Hassieb contributed to this report.