Hamas said the explosion was accidental and its men died while performing a "holy mission."
Hamas security men kept photographers and TV cameramen away from the scene. Dr. Moaiya Hassanain, a Palestinian Health Ministry official, confirmed the deaths.
The incident happened amid new signs that Israel is moving closer to a cease-fire with Hamas militants in the Gaza Strip. Amos Gilad, a senior Defense Ministry official, traveled this week to Cairo for talks with Egyptian mediators, Israeli defense officials said on condition of anonymity due to the sensitive nature of the talks.
As part of the Israel-Egypt talks, the two sides have agreed in principle for Egypt to replace Israel as the main supplier of electricity to the Gaza Strip, the officials said. Egypt will set up a new power line from the city of El-Arish, the officials said.
The deal must still be finalized. But when it's complete, Egypt will within two years build a power line to supply 150 megawatts to Gaza, the officials said. The agreement stems from Israel's desire to cut off all ties with the Gaza Strip, which it withdrew from in 2005.
Israel has imposed a blockade on the territory in recent months, including small cuts in electricity, in an effort to force Gaza's Hamas rulers to stop rocket fire into southern Israel.
An economic adviser to Salam Fayyad, the prime minister of the Palestinian government in the West Bank, said Thursday that Israel had approved the project. Fayyad's administration, Egypt and the Islamic Development Bank in Saudi Arabia have already agreed to the $32 million project, said the adviser, Jawad Al-Naji.
"We signed the agreement with the Islamic fund and with the Egyptians," Al-Naji said. "Now we have entered the executive phase after the Israeli approval."
Fayyad's government is eager to assert its authority over Gaza, which is controlled by the rival Hamas movement. Hamas officials weren't immediately available for comment.
Also Thursday, a smuggling tunnel under the Egypt-Gaza border collapsed, killing one man, doctors said. Residents said they believed another man was buried in the rubble. Palestinian smugglers use tunnels to bring everything from cigarettes to weapons into Gaza.
In other violence, Israeli troops killed a 60-year-old Palestinian farmer near Gaza's border with Israel, doctors said. The Israeli military had no comment. But Israel often shoots at Palestinians near the border due to frequent attempts by militants to plant explosives or sneak into Israel.
Israel has been battling Hamas since the Islamic group violently seized control of Gaza last June, launching military strikes and ground operations in an effort to stop the rocket fire.
But violence in the Gaza Strip and southern Israel has eased overall in recent weeks as Egypt, with U.S. backing, pressed Hamas to stop its rocket fire into Israel and urged Israel to halt military activity.
The truce efforts intensified after a fierce round of fighting that began in late February and killed more than 120 Palestinians, including dozens of civilians, as well as three Israelis.
Israeli security was on alert Thursday, believing that militant groups could try to attack during the Purim holiday, which begins at sundown and coincides with the end of a 40-day Muslim mourning period for a Hezbollah commander killed last month. Imad Mughniyeh was killed in a car bombing in Syria that the Lebanese guerrilla group blamed on Israel. Israel has denied involvement.
As part of the security cautions, Israel barred thousands of Palestinian workers and merchants from the West Bank and Gaza Strip from entering the country. The closure took effect Wednesday and would last until Monday morning, the army said.