The military says two other soldiers were wounded and evacuated to a hospital.
It says the soldiers opened fire on the militants, killing two of them.
The military says it "holds Hamas as solely responsible for maintaining peace and quiet in the Gaza Strip."
Friday's violence was some of the worst in the Hamas-run Gaza Strip since Israel's military offensive there more than a year ago.
Security officials with Gaza's Hamas-run Interior Ministry reported fire from Israeli artillery, tanks and a helicopter gunship in a sparsely populated border area near the southern city of Khan Younis. Militants responded with mortar fire, they said.
Local medical officials reported that five civilians were injured in the fighting. Footage broadcast on Al-Arabiya television showed residents crowding around ambulances that were unable to reach the scene of the fighting because of the gunfire.
The Israeli military provided no information on the clashes.
The Hamas military wing's Web site said its gunmen were involved - a departure from the Islamic militant group's tendency over the past year to avoid confrontation with Israeli forces.
Hamas spokesman Abu Obeida told Hamas radio that Israeli forces "fell into an ambush" set by Hamas militants east of Khan Younis. He did not elaborate.
The outbreak of violence highlighted the region's volatility as the U.S. pushes to get Israeli-Palestinian peacemaking back on track.
The newly announced Israeli construction in east Jerusalem derailed U.S.-mediated negotiations that Palestinians and Israelis had agreed to launch just before the diplomatic feud erupted.
The Palestinians want the eastern sector of the holy city for a future capital and view the expanding Jewish presence there as a challenge to their claim.
Prime Minister Benjamin Netanyahu's meetings with President Barack Obama and other top U.S. officials did not appear to quell U.S. anger over a major east Jerusalem construction project whose announcement in the middle of a visit by Vice President Joe Biden touched off the worst diplomatic row between the two countries in decades.
The disclosure Wednesday that 20 new Jewish homes would be built in the heart of an Arab neighborhood in east Jerusalem only increased the friction.
In the Syrian capital of Damascus, tens of thousands of Syrians and Palestinians gathered Friday for a government-orchestrated "march of anger" against Israeli construction in Jerusalem's eastern sector.
Protesters waved Syrian and Palestinian flags and pictures of Hamas leaders as they shouted anti-Israel slogans, and senior Hamas official Mohammed Nazzal condemned what he called Israel's "brutal aggression" on holy sites.
Israel annexed east Jerusalem immediately after capturing it from Jordan during the 1967 Mideast war and does not consider Jewish construction there to be settlement activity. The international community does not recognize the annexation and equates the Jewish construction there with West Bank settlements.
Should Netanyahu decide at any point to bend on east Jerusalem, he would likely do so at the expense of watching his hardline government splinter. He could, however, replace his hawkish coalition partners with the moderate Kadima Party, whose leader, Tzipi Livni, is open to sharing the holy city.
Israel's unyielding stance earned Netanyahu a chilly reception this week at the White House. In what was widely regarded as a snub, the news media were not allowed into any part of the two meetings between Obama and Netanyahu. No joint news conference was held afterward, no statements were issued about what happened, and the White House did not even release a photograph.