"Throughout the exchange of fire a number of mortar rounds were fired at IDF (military) forces and an explosive device was detonated," she said.
"The IDF force identified hitting four gunmen. Grenades and various weapons were found on their bodies."
A soldier was hospitalised with light wounds, she said.
The gun battle broke out after Israeli armoured vehicles crossed into the territory near the city of Khan Yunis, Palestinian witnesses and security officials said.
Two aircraft carried out strikes in open areas several hundred metres inside the Gaza Strip, the army spokeswoman said.
Fawzi Barhum, Hamas spokesman, called the killing of the men "an enormous Israeli crime which constitutes a grave violation of the truce".
A further five mortar rounds were fired into Israel later on Wednesday, a military spokeswoman said.
She said that no injuries or damage was reported.
Ehud Olmert, the outgoing Israeli prime minister, cautioned on Tuesday of a looming confrontation with Hamas despite the Egyptian-mediated June 19 ceasefire.
"I have no doubt that the situation between us and Hamas is an unavoidable pre-confrontation situation," he said while touring the military headquarters responsible for the Gaza region.
"It's only a question of time and not a question of if."
The renewed violence on the Gaza border came as Israel said aid deliveries to the impoverished territory would be dependent on a sustained period of calm.
After a flare-up last week, Israel further tightened the punishing blockade it imposed when Hamas seized control of Gaza last year, closing its border crossings to fuel and food deliveries by the European Union and UN.
It only allowed fuel deliveries to Gaza's sole power plant to resume on Tuesday, a day after the Palestinians said they had been forced to shut it down for want of diesel.
Israel said the decision would be reviewed daily.