Updated

The Palestinian premier wrested an agreement early Wednesday from his Hamas and the rival Fatah to stop violent incidents, hours after Hamas militants attacked a Fatah funeral procession and children were caught in a crossfire in Gaza City.

Nine Palestinians, including five children, were wounded in the gunfight in Gaza City on Tuesday morning.

Then Hamas militants attacked the funeral procession in southern Gaza for a Fatah gunman killed in a Monday clash, setting off two bombs and opening fire. Fatah gunmen dropped to the ground and returned the fire. Three unarmed bystanders were slightly wounded, hospital officials said.

The fighting broke out hours before international mediators agreed to send some aid to ease the financial siege on the Hamas-led government because of its violent anti-Israel ideology.

After a second day of violence, Palestinian Prime Minister Ismail Haniyeh summoned Hamas and Fatah leaders to his Gaza City office for talks that lasted 4 1/2 hours. Haniyeh, flanked by Fatah activists, told reporters after midnight Wednesday that the two sides agreed to put a stop to the violent clashes.

Countrywatch: Israel

Haniyeh said the they agreed that "dialogue is the only language to solve our differences." Ahmed Helas, a Fatah leader, read a joint statement with a pledge to work out problems peacefully and expel any member who uses weapons illegally.

Hamas and Fatah have been in a power struggle since Hamas won a January election. Most members of the security forces are loyal to Fatah, and instead of trying to disarm them, Hamas has set up its own militia.

Both sides are training for escalating clashes, but so far the violence has been localized and small-scale. Despite deep disagreements, Palestinians have pulled back from the brink of all-out conflict in the past.

But the burgeoning economic crisis is fraying nerves on all sides.

Severe shortages of medicines and inability to pay public sector workers are already plaguing Palestinians just five weeks after Hamas took over, showing how quickly hardships have turned into deprivation because of the Western aid cutoff and Israel's decision to withhold $55 million (euro46 million) it collects in taxes each month for the Palestinians.

Representatives of the "Quartet" of Mideast mediators -- the U.S., United Nations, European Union and Russia -- eased their stance somewhat at a meeting Tuesday in New York.

The U.S. bowed to European pressure and agreed to the funneling of humanitarian aid directly to the Palestinian people, bypassing the Hamas-led government, according to a Quartet statement. The U.S. and EU label Hamas a terror organization.

Haniyeh said he would study the decision and issue a statement on Wednesday.

Earlier, U.S. Secretary of State Condoleezza Rice said the U.S. would release $10 million (euro7.8 million) on a new medical program for the Palestinian people, but would prevent funds reaching Hamas.

The official reason for withholding funds is to prevent them from reaching Hamas, which has sent dozens of suicide bombers into Israel of the past decade, killing hundreds. Hamas Muslim ideology does not accept a Jewish state in the Middle East, and the group has rebuffed Israeli and international demands to recognize Israel, renounce violence and accept previous Israeli-Palestinian partial peace accords.

But many hope that the economic crisis will turn the people against Hamas. So far, however, there is no sign of that, beyond small demonstrations sponsored by Fatah, Hamas' main rival.

At a rally in Gaza, Haniyeh called for an end to the sanctions, but added defiantly, "We are not going to surrender, cave in to this siege, compromise the rights of our people or recognize the legitimacy of the occupiers on our land (Israel)."

Palestinian President Mahmoud Abbas, a moderate who is also the Fatah leader, appealed to Western powers to free up the funds for his people.

"Our main goal at this time is ... to end the economic siege of the Palestinian people," Abbas told reporters in the West Bank city of Ramallah, while ordering security forces to put an end to the internal violence.

Also Tuesday, the Israeli military said it foiled an attempt last week to smuggle 500 kilograms (1,100 pounds) of TNT to the Gaza Strip from Egypt by boat. Sailors saw 11 bags thrown overboard as the boat escaped. Divers retrieved the bags and found the explosives, the military said.

Israel has charged that since its pullout from Gaza last summer, arms smuggling from Egypt has increased.