Israeli troops used bulldozers to "flatten infrastructure used by terrorists to attack soldiers" before the early morning withdrawal, a military spokeswoman said.
The violence began Friday when soldiers patrolling the border crossed into Gaza after spotting Palestinians planting explosives near the fence with Israel.
Two Israeli soldiers and two Palestinian militants were killed in the gunbattle, the military said. Palestinian medics said one civilian was killed and seven were wounded in the fighting. Militants reported one wounded and one missing.
Hamas, the Islamic militant group that rules Gaza, confirmed their gunmen were involved in Friday's violence
- marking a shift from the group's tendency over the past year to avoid confrontation with Israeli forces.
The military said it holds Hamas responsible for the latest violence.
"We will not tolerate any attempt to harm the citizens of the state of Israel and we will continue to operate firmly against anyone who uses terror against it," a military statement said.
The fighting followed a string of recent Palestinian rocket attacks on southern Israel that have ratcheted up tensions along the Israel-Gaza border.
Palestinians fired another rocket into Israel after troops left Saturday, it exploded in an open field and nobody was injured.
The violence underscores some of the challenges the U.S. faces as it tries to get Israeli-Palestinian peace talks back on track.