The violence came as Hamas police and security forces stepped up measures against militants belonging to Islamic extremist groups, some of whom are known as Salafists.
The incident occurred during an arrest operation in the northern Sheikh Radwan neighbourhood with Gaza's interior ministry identifying the gunman as local Salafist leader Yussef al-Hanar, 27.
Some witnesses identified him as a Salafist leader while others said he belonged to a group affiliated with the Islamic State (IS) jihadist group.
Interior ministry spokesman Iyad Buzum said the fighting began when security forces went to his house to arrest him for unspecified "illegal activities".
Also Read
Hanar tried to flee, firing as he went. He also tried to blow himself up with a suicide vest but was shot dead before it detonated, Buzum told AFP, saying he had "tried to booby-trap his house".
Police found "explosive belts, explosive devices and rocket-propelled grenades" in the premises, he said.
Around 200 mourners attended the funeral, with Hanar's body buried in a black flag similar to that of the IS movement, an AFP correspondent said.
"Hamas is responsible" for his death, she added.
Since last summer, when Israel and Hamas fought a deadly 50-day war in and around Gaza, there have been growing signs of internal unrest between Hamas security forces and extremist splinter groups.
Experts have warned that the growing appeal of jihadist groups, particularly among Gaza's disaffected youth, could trigger a new explosion of violence in the enclave which has been ravaged by three wars with Israel in the past six years.
Although few have been claimed, they are believed to be the work of radical Salafists unafraid to challenge Hamas.
Salafists are Sunni Muslims who promote a strict lifestyle based on that of early "pious ancestors". In Gaza they have made no secret of their disdain for Hamas over its observance of a tacit ceasefire with Israel and its failure to implement Islamic law.