GAZA CITY — Israel carried out ‘‘wide-scale’’ airstrikes and deployed tanks against militant sites in Gaza, killing four Palestinians on Friday after gunmen shot at soldiers near the border, officials said.

Israel’s military said it struck eight Hamas positions after its soldiers came under fire. It later said ‘‘fighter jets commenced a wide-scale attack against Hamas military targets throughout the Gaza Strip.’’

The military had not commented on the condition of the soldiers shot but described the attack as ‘‘severe.’’

It said ‘‘Hamas chose to escalate the security situation and will bear the consequences for its actions.”

The Gaza Health Ministry said four Palestinians were killed. Hamas, the militant Islamic organization that rules Gaza, said three of the Palestinians killed were members of the group. Gaza media reported that gunmen had fired mortars toward the border.


Earlier Friday, Israel’s Defense Minister Avigdor Lieberman visited Sderot, an Israeli town near Gaza that has been hard hit by Palestinian rockets over the years. ‘‘The heads of Hamas are forcibly leading us to a no-choice situation in which we will need to embark on wide and painful military operation,’’ Lieberman said.