The building housing AFP's Gaza City office was hit in an Israeli air strike on Tuesday night, an AFP photographer and the Israeli military said.
AFP photographer Mahmud Hams, who was in the fourth-floor office at the time and was unharmed, said no AFP staff were hurt in the attack. He said at least three rockets appeared to have hit the building.
"I was in the office with a fixer and suddenly we heard an explosion," Hams said, adding that it shook the building but he didn't initially realise it had been struck.
"About five minutes passed and then we heard two more loud explosions that also shook the building," he said.
"I grabbed my cameras and left the office with the fixer and there was smoke in the hallways. We ran out of the building," he said, indicating that smoke and a fire appeared to be coming from an office on one of the upper floors.
The Israeli military confirmed targeting the eight-storey building in Gaza City's Rimal neighbourhood.
"We attacked the seventh storey of the building. From what we understand, Hamas had a military intelligence operations room there," an army spokesman said.
He described the strike as "surgical" and declined to give further details.
Later, the Israeli army spokesperson's official Twitter account also confirmed the incident.
"Minutes ago, we surgically targeted a Hamas intelligence operations center on 7th floor of a media building in Gaza. Direct hit confirmed," the account said.
"The Hamas terrorists weren't in the media building to be interviewed. They were there to communicate with field operatives and plan attacks," it added.
"Warning to reporters in Gaza: Stay away from Hamas operatives and facilities. Hamas, a terrorist group, will use you as human shields."
The official French-language account for the Israeli military posted the same comments in French, and also tweeted a message directly at AFP's French Twitter account.
"This building housed a Hamas intelligence HQ, do not be used as human shields," it said in French.
The Tuesday night attacks came after three Israeli strikes on buildings that house media offices, which the military defended, saying each raid targeted militant facilities.
The first two strikes came on Sunday, when war planes bombed the Showa and Housari building in the Rimal neighbourhood, causing extensive damage and wounding six journalists, including one who lost a leg.
The building housed various media outlets, including international stations and the Hamas-affiliated al-Quds channel.
The second raid hit the Shuruq building, which also housed various media outlets, including the Hamas-affiliated al-Aqsa television station.
The Shuruq building was hit again on Monday, in a strike that killed a senior Islamic Jihad militant, according to the Islamist faction.
Israel confirmed the attack, with its intelligence services saying the strike had targeted "senior Islamic Jihad officials" who were on the premises.
On Monday, the Israeli military said its initial strikes on the Showa and Housari and Shuruq buildings had targeted rooftop operational communications belonging to Hamas, adding that it had sought to minimise civilian casualties.
But the strikes were condemned by the local Foreign Press Association as well as international media watchdog Reporters Without Borders.