Troops from the Golani Brigade killed the four infiltrators - who were armed with Kalashnikov rifles, hand grenades and rocket-propelled grenade launchers - as they tried to enter Israeli territory from Gaza early Saturday morning.
"The incident began around 4 a.m., when observers from the Gaza Division identified a group of four suspects creeping together towards the fence," the IDF said.
"Fighters from the 12th Battalion positioned themselves in front of the squad, opposite (the town of) Deir el Balah in central Gaza.
"An exchange of fire ensued, and a grenade was thrown and guns fired, while three were directly at the border fence… and one had already crossed.
"The four terrorists wore makeshift uniforms, were armed with Kalashnikov rifles and were carrying a medical bag (and) pipe bombs," the army said.
"At the same time, a tank opened fire in order to remove a threat in the area of operations."
There were no casualties among the soldiers.
Hamas rejected any responsibility for the pre-dawn incident, saying that it was a direct result of the land and sea blockade Israel has placed on the Strip. Israel says the blockade is necessary to prevent terror attacks on its population. .
"Israel is seeing the results of the perpetual pressure and rage in which the residents of the Gaza Strip live, which is caused by the siege it imposes on the Strip," the terror group that rules the coastal enclave said in a statement.
"The actions of Israel are pushing young Gazans into independent responses," the group said.
But IDF spokesman Lt. Col. Jonathan Conricus said Israel holds Gaza's ruling Hamas authorities "responsible and accountable for any acts of violence emanating from the Gaza Strip," regardless of whether Hamas ordered the attack.
Sources in the Gaza Strip initially said that three of the dead Palestinians were members of Hamas' unit responsible for preventing infiltration into Israel near the perimeter fence.
The same sources named the three Hamas men as Abdullah Hamaida, aged 21; Abdullah a-Ghari, aged 19, and Ahmed Adini, aged 20.
The troops involved in thwarting the attack were from the 12th Battalion, which nine days ago were involved in an infiltration from Gaza a little south of the scene of the Saturday morning incident.
An IDF officer was shot dead and two soldiers were lightly wounded in the attack.