Witnesses say the dead gunmen were from the Islamic Jihad group. Another militant was wounded.
Five other civilians were also wounded in the incident, including two ambulance paramedics, two radio reporters and a civilian.
The Israeli army says their troops spotted the militants preparing to launch rockets at Israeli targets.
"The force spotted the militants and a gun battle followed in which a air force helicopter was also involved," a spokeswoman said.
There were no casualties among the Israeli force. The spokeswoman said this was the first time that Israeli troops held a gun battle with militants while inside the Gaza Strip.
However she said it was not the first time that troops had ventured into the Gaza Strip since Israel withdrew from the territory after 28 years of occupation last August. On previous occasions Israeli forces had crossed the border fence to only carry out searches.
Earlier Israeli soldiers shot dead a Palestinian gunman on the Gaza-Israel border, Palestinian and Israeli officials said.
