Summary:Under the deal, Israel has agreed to end all hostilities and targeted killings, while Hamas will stop attacks against Israel and along the border.
At least 157 people have died since the flare-up of violence began last week.
Both sides continued to fire on each other as the 21:00 (19:00 GMT) ceasefire deadline approached, but no major breaches have been reported.
Earlier, a bomb exploded on a bus in the Israeli city of Tel Aviv, leaving three people needing surgery
Wednesday also saw at least 13 people die in Gaza.
Israel has agreed to "stop all hostilities on the Gaza Strip, land, sea and air including incursions and targeting of individuals", the ceasefire deal says.
"All Palestinian factions shall stop all hostilities from the Gaza Strip against Israel, including rocket attacks and attacks along the border," it stipulates.
Hamas political leader Khaled Meshaal said Israel's offensive had "failed". He also thanked Egypt for the brokering deal, which it said met Hamas's main demands.
A statement from the office of Israeli Prime Minister Benjamin Netanyahu said he had agreed to a US suggestion "to give a chance to Egypt's proposal for a ceasefire and so give an opportunity to stabilise the situation and calm it before there will be need to apply greater force".
Egyptian Foreign Minister Kamel Amr announced the ceasefire at a news conference in Cairo with US Secretary of State Hillary Clinton, who joined negotiations on Wednesday.
For the truce to hold, Mrs Clinton said, "the rocket attacks [from Gaza] must end and a broader calm must return".
"Now we have to focus on reaching a durable outcome that promotes regional stability and advances the security, dignity and legitimate aspirations of Palestinians and Israelis alike," she added.
US President Barack Obama praised the Israeli leader for accepting the deal and said he would seek additional funding for the Iron Dome missile defence system, which destroyed dozens of rockets from Gaza in mid-air during the past week.
Copy of ceasefire deal The deal was announced in Cairo
He also thanked Egyptian President Mohammed Mursi for his efforts.
Ties between Hamas and Egypt have strengthened since Mr Mursi was elected earlier this year. Hamas was formed as an offshoot of the Muslim Brotherhood, to which Mr Mursi belongs.
Also on Wednesday, Palestinian militants fired more rockets at Israel, while Israel renewed its naval artillery bombardment of Gaza.
Israel launched its current offensive a week ago with the killing of Hamas military leader Ahmed Jabari.
The Israeli government says his assassination, and the subsequent offensive, were aimed at ending rocket fire from Gaza.
More than 150 Palestinians and five Israelis have since been killed.
Israeli officials described Wednesday's bus explosion as a "terrorist attack". Hamas praised it but has not said it was behind the blast.