Israel has bombed a building in the Gaza Strip which it says was being used by hostile hackers, the first known example of a nation responding to a cyber attack with immediate military force.

The Israeli Defence Forces (IDF) launched the air strike on Saturday in retaliation for an alleged attack on Israel's "cyberspace" by the Palestinian militant group Hamas.

A spokesman did not give details about the cyber attack, but said it had been stopped online before the air strike began, according to ZDNet. Israel's internal security service, Shin Bet, was also involved.

"After dealing with the cyber dimension, the Air Force dealt with it in the physical dimension," said Brig Gen Ronen Manlis, a spokesman for the IDF. "At this point in time, Hamas has no cyber operational capabilities."

It came amid a sharp increase in violence in Gaza, with Palestinian militants launching hundreds of rockets into southern Israel and the IDF pounding the area with air strikes, the fiercest fighting since the last Hamas-Israeli war in 2014.