Hamas in Gaza
Hamas in GazaAbed Rahim Khatib/ Flash90

Three Italian security officers left the Gaza Strip on Wednesday after an incident that saw them flee to a UN building as Hamas security pursued them, an official and a diplomatic source said.

The three were in Gaza to prepare for an upcoming visit by the Italian consul general based in Jerusalem, the diplomatic source said, and were stuck in the UN building for around a day after the incident.

They were allowed to leave after their identities were confirmed and it was determined they were not involved in any wrongdoing, a Gazan security source said.

Hamas has been on high alert following a November botched Israeli special forces operation inside Gaza.

The unusual incident began on Monday night, when the three were in a car in central Gaza as gunfire rang out, said Gaza "interior ministry" spokesman Iyad al-Bozum.

"The car then headed to a United Nations headquarters in Gaza City," he said in a statement, adding that there were suspicions about their identities.

Hamas security forces pursued them and surrounded the building, leading to a standoff.

Hamas-affiliated media reported that the Italians had refused to be searched and then fled to the UN building, but al-Bozum did not comment on this.

The Gaza security source said that through investigations they had identified the three, clarified their entrance to Gaza was legal and "that their car had no relation with the shooting incident."

The diplomatic source said the discussions with Hamas occurred through intermediaries since Italy does not have contacts with the Hamas, which the European Union labels a terrorist organization.

The security agents left the Gaza Strip on Wednesday afternoon, the source said.

Italy's foreign ministry confirmed in a statement on Wednesday that the three officers had left the UN building and thanked UN envoy Nickolay Mladenov for "having managed the situation".

It said that local authorities had been notified through the UN of the security officers' mission.