GAZA, Gaza Strip -- Israel and Gaza's ruling Hamas agreed Tuesday to an open-ended cease-fire after seven weeks of fighting -- an uneasy deal that halts the deadliest war the sides have fought in years, with more than 2,200 killed, but puts off the most difficult issues.

In the end, both sides settled for an ambiguous interim agreement in exchange for a period of calm. Hamas, though badly battered, remains in control of Gaza with part of its military arsenal intact. Israel and Egypt will continue to control access to blockaded Gaza, despite Hamas' long-running demand that the border closures imposed in 2007 be lifted.

Hamas declared victory, even though it had little to show for a war that killed 2,143 Palestinians, wounded more than 11,000 and left some 100,000 homeless. On the Israeli side, 64 soldiers and six civilians were killed, including two killed by Palestinian mortar fire shortly before the cease-fire was announced.

Large crowds gathered in Gaza City after the truce took effect at dusk, some waving the green flags of Hamas, while celebratory gunfire and fireworks erupted across the territory.

Mahmoud Zahar, a senior Hamas leader, promised to rebuild homes destroyed in the war and said Hamas would rearm. "We will build and upgrade our arsenal to be ready for the coming battle, the battle of full liberation," he declared, surrounded by Hamas gunmen.

The Israeli response was more subdued.

"This time we hope the cease-fire will stick," said Israeli government spokesman Mark Regev. He portrayed the deal as one Hamas had rejected in previous rounds of negotiations.

Israeli Prime Minister Benjamin Netanyahu faced some criticism from hard-line critics and residents of Israeli communities near Gaza who said the deal failed to defuse the threat from Gaza militants. Since July 8, Hamas and its allies have fired some 4,000 rockets and mortars at Israel, and tens of thousands of Israelis evacuated areas near Gaza in recent weeks.

Under the Egyptian-brokered deal, Israel is to ease imports to Gaza, including aid and material for reconstruction. It also agreed to a largely symbolic gesture, expanding a fishing zone for Gaza fishermen from three to six nautical miles into the Mediterranean.

In a month, talks are to begin on more complex issues, including Hamas' demand to start building a seaport and airport in Gaza. Israel has said it would only agree if Hamas disarms, a demand the militant group has rejected.

In Washington, State Department spokeswoman Jen Psaki said Tuesday that the agreement offers "an opportunity, not a certainty."

"Today's agreement comes after many hours and days of negotiations and discussions. But certainly there's a long road ahead. ... We're going into this eyes wide open," she said. Early on in the war, U.N. chief Ban Ki-moon and U.S. Secretary of State John Kerry had tried in vain to broker a truce.

The cease-fire went into effect at 7 p.m. (1600 GMT) Tuesday, and violence persisted until the last minute.

About an hour before the cease-fire, 12 mortar shells hit an Israeli communal farm near Gaza, killing two Israelis and wounding seven other people, two of them critically, the Israeli military said. Between 5 p.m. and 7 p.m., Gaza militants fired 83 rockets, of which 13 were intercepted.

In Gaza, an Israeli airstrike minutes before the start of the cease-fire toppled a five-story building in the town of Beit Lahiya, witnesses said. Twelve Palestinians, including two children, were killed in several Israeli airstrikes before the truce took hold, Gaza police said.

In Gaza City, a 20-year-old woman was killed and several dozen people were wounded by celebratory gunfire after the truce was announced.

Throughout the war, Israel launched some 5,000 airstrikes against Gaza, saying it targeted sites linked to militants, including rocket launchers and weapons depots. About three-fourths of those killed in the strikes have been civilians, according to the U.N. and Palestinian officials.

In recent days, Israel had stepped up its pressure on Hamas, toppling five towers containing offices, apartments and shops since Saturday. Two of those buildings were brought down in airstrikes early Tuesday that destroyed dozens of apartments and shops.

Hamas has emerged from the war badly battered. Just one-third of its initial rocket arsenal of 10,000 remains, according to Israel and the Islamic group's network of attack tunnels under the border with Israel has been mostly destroyed.

Despite its victory celebrations Tuesday, Hamas failed to force an end to the Gaza blockade, imposed by Israel and Egypt after the Islamic militants seized the seaside strip in 2007.

Under the restrictions, virtually all of Gaza's 1.8 million people cannot trade or travel. Only a few thousand are able to leave the coastal territory every month.

The cease-fire deal makes no mention of ending the ban on exports from Gaza or significantly easing travel.

Palestinian President Mahmoud Abbas, a long-time rival of Hamas, will likely play a key role in any new border deal for Gaza. Abbas, who lost Gaza to Hamas in 2007, is expected to regain a foothold there under any Egyptian-brokered agreement.

Forces loyal to Abbas would be posted at Gaza's crossings to allay fears by Israel and Egypt about renewed attempts by Hamas to smuggle weapons into the territory. Israel is also concerned that material for reconstruction would be diverted by Hamas for military purposes.

In a televised address Tuesday evening, Abbas said the end of the war underscored the need to find a permanent solution to the conflict with Israel.

"What's next? Gaza has been subjected to three wars. Shall we expect another war in a year or two? Until when will this issue be without a solution?" he said.

Aides have said Abbas plans to ask the U.N. Security Council to demand Israel's withdrawal from all lands captured in the 1967 Mideast war to make way for an independent Palestinian state.

Abbas alluded to the plan in his speech.

"Today I'm going to give the Palestinian leadership my vision for a solution and after that we will continue consultations with the international community," he said. "This vision must be clear and well-defined and we are not going to an open-ended negotiation."

------

Daraghmeh reported from Ramallah, West Bank. Associated Press writers Sarah El Deeb in Cairo, Josef Federman in Jerusalem, Ibrahim Barzak in Gaza City and Deb Riechmann in Washington contributed to this report.