JERUSALEM — Two Israeli soldiers and a Palestinian civilian were killed Friday as a gun battle between troops and Palestinian militants widened into some of the fiercest fighting in the Gaza Strip since Israel’s military offensive there last year.

Gaza’s Islamic Hamas rulers 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. Palestinian groups did not confirm the Israeli military’s claim that two militants were killed in the clashes.

The fighting followed a string of recent Palestinian rocket attacks on southern Israel that have ratcheted up tensions along the Israel-Gaza border. It also highlighted the challenges the U.S. faces as it struggles to get Israeli-Palestinian peace talks back on track.

Israel’s prime minister dug in his heels on one of the issues in contention Friday, insisting in defiance of U.S. pressure that the Jewish state would continue building in contested east Jerusalem. Benjamin Netanyahu’s uncompromising adherence to long-standing Israeli policy signaled that a rift with the U.S. remained wide after his White House visit this week – with stalled Mideast peace talks caught in the middle.

“The prime minister’s position is that there is no change in Israeli policy on Jerusalem,” Netanyahu’s office said.

Israel’s military said its troops crossed into Gaza after they spotted militants planting explosives along the security fence on the border. A gunfight broke out, leaving two soldiers and two militants dead, the military said.

The soldiers were the first to die in clashes with Gaza militants since Jan. 27, 2009, nine days after Israel’s military offensive in the territory ended, the military said.

Defense Minister Ehud Barak said Israel would respond if militants escalated their attacks. “We aren’t interested in returning the area to days gone by, but if we have to, we will take action,” Barak told Channel 2 TV.

Hamas official Ismail Radwan told Associated Press Television News the soldiers’ deaths were a “gift” from Hamas to Jerusalem and to Hamas operative Mahmoud al-Mabhouh, who is widely believed to have been slain by Israeli agents in a Dubai hotel in January.

Gaza medical officials reported one civilian was killed and seven were wounded in the fighting.