Interior Ministry spokesman Ihab Ghussein says the men, aged 60 years and 29 years, were hanged at dawn Tuesday.
He would not provide further details.
Angry family members of one of the executed men burnt tires and blocked a road in protest after the hanging.
The Gaza-based Palestinian Center for Human Rights says Hamas has executed five people for spying since seizing control of the coastal area in 2007.
Another seventeen alleged informers were killed in vigilante-style shootings by Palestinians during the three-week Israeli offensive in Gaza that ended in January 2009. Some were on death row or awaiting trial by Hamas.