JERUSALEM - Palestinian militants fired three homemade rockets into southern Israel on Tuesday, threatening to unravel a ceasefire days after it began, and Israel responded by closing vital border crossings into Gaza.

Despite what it called a "gross violation" of the truce, Israel refrained from military action and said it would send an envoy soon to Egypt to work on the next stage of a broader ceasefire agreement: a prisoner swap that would bring home an Israeli soldier held by Hamas for more than two years.

Hamas, the militant Islamic group that rules Gaza, promised to rein in the Iran- and Syria-backed faction that carried out the rocket attacks and pledged to remain committed to the truce that went into effect June 19 and urged restraint by all sides.

The fact that the ceasefire held up despite the severe strain was an indication that both sides had a lot at stake in the negotiations for a agreement. 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 slightly 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, one of them an Islamic Jihad area commander, 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.

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

A neighbour 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."

Israel took no military action but late Tuesday decided to shut the crossings, cutting off shipments of basic supplies that had been increased as part of the truce deal, according to defence 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.

In Berlin, the Quartet of Middle East peacemakers -- made up of the United States, the European Union, the United Nations and Russia -- called Tuesday for the ceasefire to be respected "in full" and voiced hope that the truce will last.