A federal judge Wednesday spared a central Louisiana man prison time in an accidental shooting death more than five years ago aboard an offshore oil rig.

U.S. District Judge Martin Feldman, of New Orleans, sentenced Michael Cosenza Jr. to two years of probation and one year of home detention, capping a bizarre case that devastated two families.

Cosenza, 40, of Rapides Parish, was not prosecuted for the December 2009 shooting death of Keith Beech, even though he initially fabricated a story about the man’s death and threw the pistol that killed him into the Gulf of Mexico. But he pleaded guilty earlier this year to a rarely invoked federal weapons charge — transporting a firearm aboard a vessel without notifying the captain — related to the .22-caliber Derringer he carried aboard the rig.

Cosenza ultimately acknowledged shooting Beech, a 30-year-old crane operator from Mississippi, as Cosenza “flopped” onto a sofa to watch television.

On Wednesday, for the first time, he offered an emotional apology to Beech’s wife, Amanda, who was pregnant at the time of the shooting.

“I know you’ve been through almost as much as I have,” Amanda Beech told Cosenza in response.

Feldman, at the end of the hearing, issued a stern warning to Cosenza to surrender immediately any firearms or weapon permits in his possession. Beech’s wife had said she wanted him to be stripped of his right to own a gun so that no other family might experience the kind of loss she has endured.

“You damn well better do it,” Feldman told Cosenza of ridding himself of any arms.

Cosenza’s defense attorney, Sam Scillitani, likened his client’s relationship with guns to that of oil and water. In May 2011, less than two years after the shooting, Cosenza’s wife fatally shot their 6-year-old daugther and herself in a murder-suicide in Rapides Parish.

“Everybody ends up losing in this particular case,” Scillitani said, describing Cosenza as a broken man in need of counseling.

The shooting happened Dec. 13, 2009, aboard the Hercules rig, which had been stacked — meaning it had no contract at the time — off the coast of Lafourche Parish. Cosenza and Beech were aboard the rig with two other crew members.

On the night of the shooting, Cosenza and Beech had been in the rig’s break room watching a hunting show on television called “Wildgame Nation.” Beech told Cosenza he had been considering purchasing a gun for his wife because she was often home alone at the couple’s home in Ellisville, Mississippi.

According to Cosenza, he realized before that conversation that he had inadvertently taken a pistol aboard the rig against company policy. He said he went to retrieve the weapon when he and Beech began talking about firearms, as they often did. He was showing off the pocket-sized weapon to Beech when he “flopped” onto a sofa and the gun fired, according to court documents.

The FBI investigated whether the shooting was intentional, but even Beech’s wife said she believed, from the beginning, that it was an accident.

“I have forgiveness in my heart,” she said Wednesday.

Follow Jim Mustian on Twitter, @JimMustian.