The Hamas duo managed to enter a military site, 100m east of the Sufa crossing, near Rafah in the southern Gaza Strip, on Monday, Aljazeera's correspondent reports.
An Israeli military source said the two broke through a barrier separating Israeli territory from the Gaza Strip and were trying to attack the Holit kibbutz, when they were spotted by troops.
One of the men died when an explosive charge he was carrying detonated, and the other was shot dead during a firefight, the military said.
Hamas announced in a statement that two of its fighters had been "martyred" during a "heroic operation" near a terminal crossing into Israel.
The two were named as Abd al-Aziz al-Jazzar and Abd al-Sattar al-Jafari, both members of Hamas' armed wing, the Izz al-Din al-Qassam Brigades.
Aljazeera's correspondent also reported that two members of another resistance group, Islamic Jihad, had been killed near Rafah.
The two men, named as Saadi Abu Aisha and Muhammad Ashur, were attempting to plant explosive devices at a military post near the Rafiah Yam settlement.
The onslaught has been the
deadliest in Gaza for four years
Israeli tank fire killed the two, the correspondent said.
Elsewhere in the central Gaza Strip, one Israeli soldier was injured in a gun battle near the al-Maghazi refugee camp.
Aljazeera's correspondent reported that two fighters sneaked into a military site and clashed with Israeli troops. One resistance fighter was also injured.
The killings came a day after a Palestinian related to an alleged local resistance leader in southern Gaza died of wounds he sustained in a helicopter attack.
Mahmud al-Shaikh Khalil died on Sunday after a missile attack on his brother's home in Rafah earlier this month, medics at the European hospital said.
The 26-year-old had been visiting Ahmad al-Shaikh Khalil on 11 October when the house was blown up.
The Islamic Jihad resistance group said the helicopter crew failed in their attempt to assassinate Ahmad - but hit two of his brothers.
Khalil's death brought to 130 the number of Palestinians killed in the Gaza Strip in the past three weeks after the Israeli army began its latest invasion into the tiny territory.
The death on Sunday brings the total number of people killed since the September 2000 start of the Palestinian uprising to 4494, including 3466 Palestinians and 954 Israelis.