An Israeli military statement, apparently referring to the same incident, said that the army returned fire after shots were fired at its soldiers from a Hamas post in the northern Gaza Strip, next to the border with Israel.
The military exchange occurred as reports that Israel and Hamas would commit to a cease-fire agreement.
Palestinians militants have also fired rockets into Israel and the Israeli military has carried out dozens of air strikes in the enclave.
It said Ahmad Morjan and Abed el-Hafeth el-Sillawi, both aged 23, were killed in the shelling, adding that no injuries were brought to hospital.
There have been reports about talks between Palestinian factions, Egypt, the United Nations and Israel to reach a long-term truce in the besieged enclave.
"The resistance can not allow the occupation to impose a policy of bombing sites and targeting fighters without paying the price", it said in a statement.
The ongoing popular demonstrations have been violently suppressed by Israeli forces, who have killed 160 Palestinians and injured over 17,000 more, according to numbers from the Gaza Ministry of Health.
One Israeli soldier has been shot dead by a Palestinian sniper during the same period, while incendiary devices attached to balloons and kites launched by Palestinians have sparked hundreds of fires in southern Israel, burning some 3,000 hectares (7,400 acres) of forest and farmland.
Human rights groups have accused Israeli troops of using excessive force at the protests.