CAIRO -- Israel and Hamas agreed to a cease-fire on Wednesday, the eighth day of lethal fighting over the Gaza Strip, in a deal completed under strong American and Egyptian diplomatic pressure that quieted an aerial battle of rockets and bombs and forestalled -- for now -- an escalation into an Israeli invasion.
The cease-fire, which took effect at 9 p.m. local time (2 p.m. Eastern), was formally announced by Secretary of State Hillary Rodham Clinton and Foreign Minister Mohamed Amr of Egypt after intensive negotiations in Cairo. It was welcomed by all sides, but whether the cease-fire could hold was uncertain.
Even in the minutes leading up to the effective start time, the antagonists were firing at each other, and the Israeli authorities reported at least five Palestinian rockets were lobbed into southern Israel shortly after the cease-fire had begun. But no damage or injuries were reported and the rocket fire seemed to end in the second hour. In Gaza, thousands of residents came outside to celebrate.
"This is a critical moment for the region," Mrs. Clinton, who rushed to the Middle East late Tuesday in an intensified effort to halt the hostilities, told reporters in Cairo. She thanked Egypt's president, Mohamed Morsi, who played a pivotal role in the negotiations, for "assuming the leadership that has long made this country a cornerstone of regional stability and peace."
Mrs. Clinton also pledged to work "with our partners across the region to consolidate this progress, improve conditions for the people of Gaza, provide security for the people of Israel."
Mr. Amr said Egypt's role in reaching the agreement reflected its "historical commitment to the Palestinian cause" and Egypt's efforts to "bring together the gap between the Palestinian factions."
The top leader of Hamas, Khaled Meshal, also had strong words of praise for the Egyptian leader, a former official in the Muslim Brotherhood, in which Hamas has roots. At a news conference in Cairo, Mr. Meshal thanked Egypt for its role and said Israel had "failed in all its objectives."
The negotiators reached an agreement after days of nearly nonstop Israeli aerial assaults on Gaza, the Mediterranean enclave run by Hamas, and the firing of hundreds of rockets into Israel from an arsenal Hamas had been amassing since the three-week Israeli invasion four years ago.
Under the terms distributed after the cease-fire was announced, Israel agreed to stop all land, sea and air hostilities in Gaza, including the "targeting of individuals" -- a reference to militants of Hamas and its affiliates who have been killed. The cease-fire also called on the Palestinian factions in Gaza to stop all hostilities against Israel, including rocket attacks and attacks along the border.
But the terms also state that underlying grievances of Gazans, most notably the border restrictions Israel has imposed that impede the movement of people and goods through Gaza, will be addressed starting 24 hours after the cease-fire is in effect. Precisely how they will be addressed was left unclear.
Also left unclear was how the agreement would be enforced, but the terms stated that "each party shall commit itself not to perform any acts that would breach this understanding."
The agreement came despite a bus bombing in Tel Aviv earlier in the day, applauded by Hamas and other Palestinian militant groups, which invited Israeli reprisals and threatened to derail the talks. Also complicating the path to the cease-fire were Israeli strikes overnight on Gaza.
Prime Minister Benjamin Netanyahu of Israel, who had been threatening to start another ground invasion if the Gaza rockets did not stop, said in a statement that he was satisfied, for the moment, with the outcome. But he left open the possibility of more military action.
The statement issued by his office said Mr. Netanyahu had spoken with President Obama and "responded positively to his recommendation to give a chance to the Egyptian proposal for a cease-fire and to allow an opportunity to stabilize the situation and to calm it down before there is a need to use much greater force."
An agreement had been on the verge of completion on Tuesday, but was delayed over a number of issues, including Hamas's demands for unfettered access to Gaza via the Rafah crossing into Egypt and other steps that would ease Israel's economic and border control over other aspects of life for the more than one million Palestinian residents of Gaza, which Israel vacated in 2005 after 38 years of occupation.
The Hamas Health Ministry in Gaza said the Palestinian death toll after a week of fighting stood at 140 at noon. At least a third of those killed are believed to have been militants. On the Israeli side, five Israelis have been killed, including one soldier.
Around noon on Wednesday in the Gaza Strip, according to the Hamas government media office, a bomb hit the house of Issam Da'alis, an adviser to Ismail Haniyathe Hamas prime minister. The house had been evacuated. Earlier, a predawn airstrike near a mosque in the Jabaliya refugee camp killed a 30-year-old militant, a spokesman said, and F-16 bombs destroyed two houses in the central Gaza Strip.
There were 23 punishing strikes against the southern tunnels that are used to bring weapons as well as construction material, cars and other commercial goods into Gaza from the Sinai Peninsula.
Within Gaza City, Abu Khadra, the largest government office complex, was obliterated overnight. Businesses were also damaged, including two banks and a tourism office, and electricity cables fell on the ground and were covered in dust.
Separately, a bomb dropped from an F-16 created a 20-foot-wide crater in an open area in a stretch of hotels occupied by foreign journalists. Several of the hotels had windows blown out by the strike around 2 a.m., but no one was reported injured. By morning, the hole in the ground had filled with sludgy water, apparently from a burst pipe, appearing almost like a forgotten swimming hole with walls made of sand and cracked cinder block.
Surveying damage near a government complex, Raji Sourani of the Palestinian Center for Human Rights said Gaza civilians were "in the eye of the storm," and accused Israel of "inflicting pain and terror" on them. Israeli officials accuse Hamas of locating military sites in or close to civilian areas.
Overnight, as the conflict entered its eighth day, the Israeli military said in Twitter posts that "more than 100 terror sites were targeted, of which approximately 50 were underground rocket launchers." The targets included the Ministry of Internal Security in Gaza, described as "one of Hamas's main command and control centers."
While there was no immediate or formal claim of responsibility for the bus bombing in Tel Aviv, a message on a Twitter account in the name of Al Qassam Brigades, the armed wing of the Hamas authorities in the Gaza Strip, declared: "We told you IDF that our blessed hands will reach your leaders and soldiers wherever they are, 'You opened the Gates of hell on Yourselves.' " The letters I.D.F. refer to the Israel Defense Forces.
On several occasions since the latest conflagration seized Gaza last week, militants have aimed rockets at Tel Aviv, but they either fell short, landed in the sea or were intercepted. Hundreds of rockets fired by militants in Gaza have struck other targets.
But the bombing seemed to be the first time in the fighting that violence had spread directly onto the streets of Tel Aviv.
On Tuesday -- the deadliest day of fighting in the conflict -- Mrs. Clinton arrived hurriedly in Jerusalem and met with Mr. Netanyahu to push for a truce.
Her visit to Cairo on Wednesday to consult with Egyptian officials in contact with Hamas placed her and the Obama administration at the center of a fraught process with multiple parties, interests and demands.
Before leaving for Cairo, Mrs. Clinton visited the West Bank to meet Mahmoud Abbas, the head of the Palestinian Authority, which is estranged from the Hamas rulers of the Gaza Strip and has increasingly strained ties with Israel over a contentious effort to upgrade the Palestinian status at the United Nations to that of a nonmember state. Mr. Abbas's faction is favored by the United States, but was is not directly involved in either the fighting in Gaza or the effort in Cairo to end it. Like Israel and much of the West, the United States regards Hamas as a terrorist organization.
David D. Kirkpatrick reported from Cairo, Ethan Bronner from Jerusalem and Rick Gladstone from New York. Reporting was contributed by Jodi Rudoren and Fares Akram from Gaza, Isabel Kershner from Jerusalem, Alan Cowell from London, Andrea Bruce from Rafah and Christine Hauser from New York.
This article originally appeared in The New York Times.