An Italian man has confessed to setting off the explosions that killed three firefighters at a farmhouse he owned as part of an insurance scam that went wrong, a prosecutor said Saturday.

Giovanni Vincenti was detained Friday night and told investigators he deliberately blew up his farmhouse in the northwestern Piedmont region by triggering gas canisters, prosecutor Enrico Cieri said at a news conference.

3 ITALIAN FIREFIGHTERS KILLED AFTER EXPLOSION RIPS THROUGH FARMHOUSE IN SUSPECTED DELIBERATE ATTACK

But Vicente allegedly made a mistake with a timer connected to the canisters and triggered a second explosion after firefighters had already entered the building.

He told investigators he had no intention of killing the firefighters, Cieri said.

The firefighters had been responding to an explosion in the Alessandria province of Piedmont around midnight on Tuesday, Italian daily La Repubblica reported at the time. As they worked to put out the fire, a second blast went off and leveled the building.

The body of one firefighter was buried underneath rubble from the collapsed building and recovered after hours of digging. Three other first responders suffered injuries.

Cieri said the deaths could have been prevented if Vicenti told firefighters there were more gas canisters in the house.

ITALIAN COUPLE ESCAPE HOME DURING LANDSLIDE THANKS TO THEIR CATS: 'WE SAW CRACKS OPENING IN THE WALLS'

Vicenti allegedly tried to make the false insurance claim to pay off debts. A manual for the timer was found in Vicenti’s bedroom, Cieri said. Vicenti’s wife was also under investigation.

On Friday, funerals were held for the firefighters, identified as Marco Triches, Matteo Gastaldo and Antonino Candido. The fire service shared video of fellow firefighters carrying the three caskets at the cathedral.

CLICK HERE FOR THE FOX NEWS APP

Italian Premier Giuseppe Conte attended the funeral along with other dignitaries.

“I was moved to see the long and silent embrace of the community, which came to pay tribute to these boys and their courageous colleagues who risk their lives every day to guarantee the safety of all of us,” Conte tweeted.

The Associated Press contributed to this report.