Israel and the Hamas Islamist group which controls the Gaza Strip have agreed to a ceasefire after five days of cross-border violence, officials said Monday.

One official who was involved in mediating talks between Israel and Palestinian factions in Gaza told Reuter the groups had reached an understanding on a truce and that the truce has started.

A Palestinian official said Hamas had agreed to enforce the ceasefire on smaller militant groups which were responsible for most of the rockets fired at Israel in the recent surge in violence.

On Sunday, Egypt and Israel tried to defuse a diplomatic crisis over the killing of five Egyptian security personnel during an Israeli operation against cross-border raiders, as crowds of Egyptians protested angrily at the Israeli Embassy in Cairo.

The crisis began when five Egyptian security personnel died as Israeli forces pursued a Palestinian faction who killed eight people in southern Israel on Thursday. Israel said the group entered Israel from the Gaza Strip via Egypt's Sinai desert.

Several hundred protesters remained in front of the Israeli Embassy near the Nile waterfront Sunday, watched over by hundreds of troops and police. Some said they would stay until Israel's ambassador was ejected from Egypt.

One demonstrator scaled several floors of the high-rise embassy building overnight to tear down the Israeli flag and replace it with an Egyptian one. Ahmad al-Shahat quickly shot to fame on Twitter under the name Flagman, while newspapers and one would-be Egyptian leader feted him as a hero.

Hamdeen Sabahy, the Egyptian presidential candidate, sends a salute of pride to Ahmad al-Shahat, the public hero who burned the Zionist flag that spoiled the Egyptian air for 30 years, Sabahy said.

A protest of any size near the Israeli Embassy would have been quickly smothered by state security under former President Hosni Mubarak.

The Cairo-based Arab League condemned the Israeli attack on the Egyptian forces in a statement and said Israel bore full responsibility for this crime.

The Arab League Sunday also condemned Israeli air assaults on the Gaza Strip and said the United Nations must take action to end the attacks, in which 15 people have died.

We issued a statement condemning the Israeli offensive on Gaza ... and Egyptian land, Arab League Secretary-General Nabil Elaraby told reporters in Cairo.

The United Nations has to take procedures to stop the Israeli offensive on Gaza, he said, without giving details of the measures he was urging the U.N. to take.

But there were signs that Egypt and Israel were both trying to ease the gravest crisis in their relations since Mubarak's overthrow.

Egypt said on Saturday it would recall its ambassador from Israel after the killings, but it was unclear whether the withdrawal was going ahead.

Israeli Defense Minister Ehud Barak on Saturday said Israel regretted the deaths and told the army to conduct an investigation with Egypt, which responded with cautious approval.

On Sunday evening Egypt's state media reported that Israeli President Shimon Peres expressed his regrets in a phone call with the Egyptian ambassador to Tel Aviv, Yasser Reda.

Peres held a Ramadan dinner earlier on Sunday for senior Arab officials at his home in Jerusalem where he told Egyptian diplomat Mustafa al-Kuni that he has great respect for the Egyptian people, according to Israel's Ynet news Web site.

A delegation led by an unidentified high-ranking Israeli envoy arrived in Cairo on a private plane from Tel Aviv on Sunday to a low-key reception, airport sources said.

U.S. Assistant Secretary of State Jeffrey Feltman arrived in Cairo on Sunday evening to meet Egyptian officials, according to a source at the American Embassy in Cairo.

The U.N. Special Coordinator for the Middle East Peace Process Robert Serry visited Egypt on Sunday and held talks with government officials including Foreign Minister Mohamed Kamel Amr, Chief of Intelligence Murad Muwafi and Elaraby, a U.N. press release said.

The special coordinator conveyed to the government of Egypt his deep concern over the death of Egyptian security personnel, the statement said, adding that Serry was worried about the continuing tensions, in particular the escalation of violence in Gaza and southern Israel.

The head of Egypt's ruling military council, Field Marshal Mohamed Hussein Tantawi, met ministers in a crisis management committee on Sunday to discuss the events in Sinai, state media said.

Barak said: We highly appreciate the responsibility the Egyptian government is showing (regarding) the peace agreement and I expressed directly the Israeli regret at the loss of life of Egyptian security people during the incident.

The spat has highlighted the dilemma faced by the generals ruling Egypt, caught between pressure to preserve the 1979 peace treaty with Israel and popular hostility to the Jewish state.

The army is trying to keep a lid on social tensions as Egypt prepares for elections later in the year as part of a promised transition to democratic civilian rule after Mubarak's removal.

Egypt's condemnation of Israel in a statement after a second Cabinet crisis meeting on Saturday was unusually blunt.

Egyptian blood is not cheap and the government will not accept that Egyptian blood gets shed for nothing, state news agency MENA quoted a Cabinet statement as saying.

The Israeli military killed the leadership of the faction it said was responsible for last week's attack in an air strike in Gaza on Thursday and launched more than a dozen more raids on Friday. Medical officials say at least 15 Palestinians were killed, including five civilians, three of them children.

Israel said it was acting in self-defense and did not rule out further action to prevent the launch of rockets and missiles against Israeli cities.

(Reporting by Yasmine Saleh, Ali Abdelatti, Amr Dalsh, Omar Fahmy and Ayman Samir in Cairo and Ori Lewis and Allyn Fisher-Ilan in Jerusalem; Writing by Tom Pfeiffer; Editing by Maria Golovnina)