Palestinian militants fired three homemade rockets into southern Israel on Tuesday, threatening to unravel a fresh cease-fire, and Israel responded by closing vital border crossings into Gaza.

Israel condemned the attack as a "gross violation" of the truce that went into effect on Thursday. Late Tuesday, it decided to shut the crossings, cutting off shipments of basic supplies that had been increased as part of the truce deal, according to defense officials, speaking on condition of anonymity because the decision had not been made public. There was no word on when the crossings would be reopened.

But signaling it would still honor the truce, Israel said an envoy would soon head to Egypt to work on the final stage of the agreement: a prisoner swap that would bring home an Israeli soldier held by Hamas for more than two years.

Despite the rocket fire, Hamas, the militant Islamic group that rules Gaza, said it remained committed to the truce and urged restraint by all sides.

The endorsement by both sides indicated they each had high stakes in play. Hamas wants to show it can break the Israeli blockade and provide much-needed relief to Gaza's beleaguered residents, while Israel wants to stop the daily rocket fire that has disrupted the lives of thousands of its citizens.

The midafternoon barrage, which lightly wounded two people, capped a day of violence that presented the truce with its first serious test. Just before midnight, Palestinian militants fired a mortar shell into an empty area in southern Israel. And in a pre-dawn raid, Israeli troops killed two Palestinians in the West Bank city of Nablus.

Islamic Jihad, a militant group backed by Syria and Iran, claimed responsibility for the rocket fire from Gaza. Although the West Bank is not included in the truce agreement, the group said the rockets were retaliation for the Nablus raid, which killed one of its area commanders.

"We cannot keep our hands tied when this is happening to our brothers in the West Bank," the group said.

A neighbor said a Palestinian bystander was also shot to death by troops when he opened the door of his apartment during the raid. The Israeli military said the man was a militant killed during a gunbattle with troops.

Hamas accused Israel of provoking the rocket fire but moved quickly to lower tensions and said it would talk to Islamic Jihad to ensure quiet.

"We in Hamas are committed to the calm. We will talk and we will make sure that all of the factions are committed to the calm, too," said spokesman Sami Abu Zuhri.

Israeli government spokesman David Baker called the rocket fire "a gross violation of the calm."

The Egyptian-brokered deal aims to end a year of violence that has killed more than 400 Palestinians, including dozens of civilians, and seven Israelis in a bloody cycle of Palestinian rocket attacks and Israeli reprisals.

In its final stage, Egypt hopes to mediate a deal in which Israel would release Palestinian prisoners in exchange for Sgt. Gilad Schalit, an Israeli soldier captured by Palestinian militants in a cross-border attack in June 2006.

Hamas' larger goal is for Israel to reopen Gaza's strategic border crossing with Egypt. The Rafah crossing has been sealed since the Hamas takeover, preventing the vast majority of Gaza's 1.4 million people from traveling in and out of the area. Israel has said Rafah will open only after the captured soldier returns home.

Israeli Prime Minister Ehud Olmert and Egyptian President Hosni Mubarak held talks Tuesday in the Egyptian Red Sea resort of Sharm el-Sheik, focusing on the issues of the soldier and the crossing. An Israeli official with Olmert's delegation said Egypt gave "assurances" that Rafah would not open without the soldier's release.

Israel has balked at Hamas' demands that some 450 prisoners be released in exchange for the soldier. Israel, which holds some 10,000 Palestinian prisoners, says the list of names submitted by Hamas is full of militants involved in deadly attacks.

After the summit, officials from all sides said Egypt is working to bring Israel and Hamas into proximity talks in the coming days to negotiate the exchange and solidify the truce. In the talks, which could start late this week or early next week, Egyptian mediators would shuttle between Israeli and Hamas delegations in separate locations in the Egyptian capital, Cairo.

In an interview with Israel TV, Mubarak said it would have been "unrealistic" to condition the truce agreement on release of the soldier, as some critics of the agreement demanded.

He said it was more important to stop the killing on both sides. "We must remain optimistic," Mubarak responded when asked if he thought the truce would hold, but warning, "both sides can make trouble if they want."

Israeli officials said the top Israeli negotiator on the prisoner swap, Ofer Dekel, is to travel to Cairo on Thursday. Despite Tuesday's rocket attack, Prime Minister Ehud Olmert's spokesman, Mark Regev, said there were no plans to alter Dekel's schedule.

A Hamas official said the proximity talks could begin Sunday, and underlined that its delegation would not be in the same building as the Israelis.

"Our demands are still the same, that the prisoners whose names we handed over to the Egyptians previously must be released," said Osama al-Muzzini, a Hamas spokesman in Gaza.

The cease-fire is meant to avert an Israeli invasion of Gaza, a tiny, impoverished seaside territory of 1.4 million people that Israel evacuated in 2005 after a 38-year military occupation. The deal extends beyond Hamas to all militant groups operating in Gaza but does not include the West Bank.

Israel continues to arrest wanted men in the West Bank, saying the Palestinians have not done enough to control militants there.