GAZA CITY, Gaza Strip – An Egyptian-brokered cease-fire agreement to end eight days of clashes between Israel and the Islamist group Hamas in the Gaza Strip relies heavily on the goodwill of two of the Middle East’s most bitter enemies, but gave each enough to claim success.

By the time the truce took effect Wednesday evening, 162 Palestinians and five Israelis had died. Nearly half the Palestinian dead and all but one of the Israelis were civilians.

In a sign of the two sides’ lingering animosity, clashes continued right up to the deadline, with Hamas sending a barrage of rockets at several Israeli cities and Israeli aircraft pounding a few final targets in Gaza.

Gaza residents, who were worried about the possibility of an Israeli ground offensive, poured into the streets after the cease-fire took effect, shooting guns in celebration, waving flags and setting off fireworks. In Israel, where a bomb exploded on a Tel Aviv bus earlier Wednesday and injured 21 people, the news was also welcomed. But many there questioned whether the peace would last.

The deal fell well short of the multiyear, internationally monitored agreement that had been discussed earlier in the week. But it allowed both Israel and Gaza to declare victory, and it elated Egyptian officials, who believe it proved that untested President Mohamed Morsi was up to the task of brokering a truce.

The Obama administration, which initially seemed reluctant to take a leading role in the talks, vowed to work in the coming days to enforce and expand the deal. Secretary of State Hillary Rodham Clinton arrived in the region Tuesday to help push through a settlement.

“In the days ahead, the U.S. will work to end the violence and to improve conditions for the people of Gaza and to help support the safety of the people of Israel,” she said during a news conference in Cairo. “Ultimately, every step must move towards peace for everyone in the region.”

In a one-page “understanding” that bears no signatures and does not mention Hamas by name, Israel agreed to end all hostilities on land, sea and air, and to halt targeted assassinations of militant leaders.

Hamas and other Palestinian factions in Gaza agreed to stop rocket and border attacks against Israelis. Egypt will serve as a referee.

The possibility of easing border restrictions to permit the movement of goods and people to and from the Gaza Strip, a key demand of Hamas, is to be discussed at a later date.

But Hamas officials said they received private assurances from Egypt that its Rafah border crossing with the Gaza Strip will be expanded to include goods, essentially ending a blockade that had been imposed on Gaza since 2006.

For Israeli Prime Minister Benjamin Netanyahu, the truce means he won’t have to proceed with a ground invasion just two months before he faces re-election. And if it holds, it could finally provide a respite from the barrage of thousands of rockets that have paralyzed the lives of southern Israelis for years.

The Israel Defense Forces said it had decimated Hamas’ cache of long-range rockets, killed 30 senior militant operatives of Hamas and allied groups such as Islamic Jihad, destroyed hundreds of rocket launchers, and bombed 140 smuggling tunnels to Egypt.

“Hamas and Islamic Jihad have suffered a painful blow,” said Israeli Defense Minister Ehud Barak.

Israel failed to receive the assurances it sought from Egypt that Hamas would not be allowed to rearm. But Netanyahu said Israel had reached an agreement with the U.S. to work together to prevent weapons from being funneled from Iran to Gaza.

Hamas used the conflict to reaffirm its reputation as the strongest Palestinian resistance army, extending the reach of its rockets for the first time to Tel Aviv and Jerusalem. To the degree that the deal eases the blockade affecting Gaza’s 1.5 million residents, Hamas will score significant political points in its rivalry against the secular Fatah party in the West Bank.

Whether the truce holds remains to be seen. Though most of the major Palestinian factions joined Hamas in Cairo to negotiate the deal, smaller, al-Qaida-inspired extremist groups in Gaza have proved difficult to control.

Even after the cease-fire took effect, about half a dozen rockets were fired into Israel.

The cease-fire talks drew Cairo and Washington closer together and marked the end of three decades of foreign policy by deposed Egyptian leader Hosni Mubarak, who was often criticized for siding with Israeli interests over those of the Palestinians.