Israel and Hamas agreed on a truce that will take effect Wednesday evening in a bid to end a week of bloodshed in and around Gaza that has killed more than 150 people, Egypt and the United States said.
Egyptian Foreign Minister Mohammed Kamel Amr, speaking at a joint news conference in Cairo with US Secretary of State Hillary Clinton, said the cessation of hostilities would begin at 1900 GMT.
The accord, a copy of which was obtained by AFP, calls on Israel to "stop all hostilities... in the land, sea and air including incursions and targeting of individuals" and the Palestinian factions urged to end "rocket attacks and all attacks along the border".
If it holds, within 24 hours, Israel would be required to start procedures to open Gaza's border crossings and allow the movement of people and goods, according to the text.
"This is a critical moment for the region," Clinton said as she welcomed the agreement. "In the days ahead, the United States will work with partners in the region to consolidate this progress."
Nearly 24 hours after a truce had been expected to take hold, and after a day of violence that killed another 17 Palestinians, Israeli Prime Minister Benjamin Netanyahu's office said he was prepared to give peace a chance.
"Netanyahu spoke with (US) President Barack Obama and agreed to his recommendation to give a chance to an Egyptian proposal for a ceasefire and thereby give an opportunity for the stabilisation of the situation and a calming of it," said a statement.
It won him praise from Obama.
"The president commended the prime minister for agreeing to the Egyptian ceasefire proposal, which the president recommended the prime minster do, while reiterating that Israel maintains the right to defend itself," the White House said.
In Cairo, Hamas chief Khaled Meshaal was due to give a news conference following the announcement, Hamas sources told AFP.
The agreement came after a day of shuttle diplomacy -- led by Clinton and UN Secretary General Ban Ki-moon -- which was marred by more deadly cross-border violence between Israel and militants in Gaza.
Hopes for a truce appeared to have been faint just hours earlier as a blast tore through a bus in Tel Aviv and Israel hit back with deadly air raids on Gaza City and elsewhere in the coastal Palestinian territory.
The conflict had threatened to take a new turn on Wednesday when the bomb struck the commuter bus in Israel's commercial capital, injuring 17 people and sparking panic.
The blast occurred very close to the Israeli defence ministry and was quickly denounced by Netanyahu's spokesman, who tweeted: "This was a terrorist attack".
The windows of the bus were blown out and its seats contorted from the force of the explosion, in scenes reminiscent of the second Palestinian intifada.
"I am speechless. This is scary," said Sigalit, a 22-year-old waitress working nearby.
Condemnation poured in, with Washington branding it "outrageous," Moscow denouncing it as a "criminal," and France and Germany calling for an urgent and lasting ceasefire in Gaza.
Soon after, another six Palestinians were killed in air strikes on Gaza City, raising the day's toll to 11, Palestinian medics said.
One of the strikes hit the building housing AFP's offices, killing a toddler in a neighbouring building, a health ministry spokesman said. No AFP journalists were inside at the time.
The Israeli military had no immediate comment on the strike, the second to hit the building in 24 hours.
Another air strike shortly afterwards on central Gaza killed a four-year-old girl, medics said.
The chances of a ceasefire appeared dim only hours earlier, with UN chief Ban saying after talks in Egypt with President Mohamed Morsi that there were still "many details to work out".
"We all know there are many details to work out but while that happens, civilians continue to die and cities continue to be targeted. And that's why we need a ceasefire right now, immediately," he told reporters in Cairo.
Israel launched its offensive on November 14 with the targeted killing of a Hamas military chief, hitting more than 1,500 targets. At least 148 Palestinians and five Israelis have been killed.
Gaza militants fired more than 1,500 rockets at the Jewish state, killing three people and injuring dozens, and Israel's vaunted Iron Dome anti-missile system intercepted 421 of them.
The conflict came as Israel heads towards a general election in January, and raised the spectre of a broader military campaign along the lines of the Jewish state's devastating 22-day operation launched at the end of December 2008.