Police in the US state of New York have said that a man who shot dead two firefighters had served 17 years in prison for killing his grandmother.

Two other firefighters were injured in today's attack, which happened in the town of Webster, near Lake Ontario.

A third victim, who is an off-duty police officer, was hit by stray gunfire as he was driving by the scene.

Local police said that the gunman, who was found dead at the scene, set fire to a car and house to lure the fire services to his house.

"It does appear that it was a trap that was set for... first responders," Webster Police Chief Gerald Pickering said at a press conference carried by local television.

The individual believed to be the assailant was found dead of gunshot wounds at the scene, near one of four burning homes.

"We don't know if it was self-inflicted or not," Mr Pickering said in reference to the gunman, adding that the sequence of the attack remains unclear.

The shooting this morning happened in a quiet neighbourhood of seasonal and year-round homes.

Police say four homes in all were destroyed and four damaged by the spreading flames.