They were responding to an emergency call in the town of Webster in New York state on Monday morning.
The blaze broke out just before 06:00 local time and officers had to evacuate nearby residents in an armored car.
A gunman was later found dead at the scene, the police said.
The man was 62-year-old William Spengler, Webster Police Chief Gerald Pickering told media.
William Spengler appeared to have shot himself in the head, Gerald Pickering said.
He had previously served a 17-year jail sentence after being convicted of killing his grandmother.
William Spengler’s sister is unaccounted for and police fear she may have died in the fire, which engulfed seven houses.
The two dead firefighters were named by police as Tomasz Kaczowka and Mike Chiapperini.
Gerald Pickering told reporters: “It does appear it was a trap.
“These people get up in the middle of the night to go put out fires; they don’t expect to be shot and killed.”
The two injured firefighters were named as Joseph Hofsetter and Theodore Scardino.
They are being treated for gunshot wounds at the Strong Memorial Hospital and are expected to recover.
Another passer-by was also injured in the shooting.
Police spokesmen said the area was “an active crime scene” but that no more shooters were believed to be present.
Roger Vercruysse, described as a friend of William Spengler, was quoted by the Associated Press as saying that the shooter “couldn’t stand” his sister, who lived with him.
Roger Vercruysse said that William Spengler “loved his mama to death”, adding that he “went crazy” after she died in October.
Two of the firefighters had arrived in a fire engine and two in their own vehicles, police said. One wounded man managed to escape but the others were pinned down until the armored car could be sent in.
Police evacuated residents and firefighters were then able to return to tackle the blaze.
Chief Gerald Pickering said: “Webster is a tremendous community. We are a safe community, and to have a tragedy befall us like this is just horrendous.”
New York Governor Andrew Cuomo said in a statement: “All of our thoughts and prayers go to the families and friends of those who were killed in this senseless act of violence.”
New York Attorney General Eric Schneiderman said: “The contributions made by the fallen and injured officers in Webster will never be forgotten.
“As this investigation unfolds, we stand with our partners in law enforcement to ensure that lethal weapons are out of the hands of dangerous people, so that the brave New Yorkers who risk their lives every day to protect us are not exposed to additional danger.”
There were also two separate incidents of on-duty police officers being shot dead on Monday.
A policeman was killed in the city of Houston, Texas, after the driver of a car he pulled over opened fire on him.
In the midwestern state of Wisconsin, a policewoman on early morning patrol was found shot dead in the town of Wauwatosa.
The debate on gun violence in the US was rekindled earlier this month by the shootings at a school in Newtown, Connecticut, which left 20 children and six adults dead at Sandy Hook Elementary School.
It was one of the worst mass shootings in American history.
“There’s a heightened awareness to this kind of violence in light of what happened in Connecticut,” said Maggie Brooks, leader of the local administration in Monroe County, the area which includes Webster.
“We have first responders and we have families who are in pain and crisis today and we need to, as a community, keep them in our thoughts and prayers,” Maggie Brooks said, adding that it was a “very, very difficult day”.
President Barack Obama has promised to push for action on gun control while the National Rifle Association (NRA) has called for armed security in all American schools.
6aEmeUuTTAAQuincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…
Misleading allegations, rumours and outright lies about voting and fraud are flooding online spaces in…
At least 158 people have died in Spain's worst flooding disaster in generations. On October…
Google has been fined two undecillion (a two followed by 36 zeroes) roubles by a…
Embarking on a home remodel is an exciting journey, promising enhanced comfort, increased property value,…
The US presidential candidates continued to campaign across key swing states on October 20. Footage…