A federal court judge sentenced two Colorado farmers on Tuesday to six months of home detention and five years probation for their role in a deadly 2011 listeria outbreak linked to contaminated cantaloupes.

Eric and Ryan Jensen, brothers who are former owners of Colorado-based Jensen Farms, pleaded guilty in October to six counts of adulteration of a food and aiding and abetting, linked to one of the deadliest U.S. outbreaks of foodborne illness.

"I must deliver both justice and mercy at the same time," U.S. Magistrate Judge Michael Hegarty said during a hearing in Denver.

Explaining his reason for not sending the brothers to jail, Hegarty said he wanted to preserve their ability to earn enough income to pay restitution of $150,000 each to the families of those who died and other victims in the case.

Prosecutors said they recommended probation in the case because of the brothers' demonstration of remorse and their cooperation with authorities investigating the outbreak.

Both will be allowed to leave their homes for work, to attend church and for certain educational purposes under the sentence. Each brother had faced a possible maximum sentence of six years in prison and $1.5 million in fines.

The Jensens' cantaloupes were processed and packed at a plant in Granada, Colorado, but equipment there failed to wash the melons with enough anti-bacterial solution to remove listeria bacteria, prosecutors said in court papers.

U.S. health officials have reported that a total of 147 people in 28 states fell ill in the outbreak, including 33 who died. Assistant U.S. Attorney Jaime Pena, however, said in court on Tuesday the death toll was closer to 40.

Pregnant women and others with compromised immune systems are particularly vulnerable to listeria infection, which has a mortality rate of about 20 percent and is the third-leading cause of death from food poisoning, according to the Centers for Disease Control and Prevention in Atlanta.

Symptoms include fever, muscle aches, nausea or diarrhea, stiff neck, confusion and in severe cases convulsions and meningitis. The infection can also cause pregnant women to miscarry.

Pena said the magnitude and scope of the Jensen Farms outbreak was a key reason for prosecuting the brothers, even though he believed they "did not intentionally and knowingly allow adulterated food to leave their premises."

U.S. Attorney John Walsh said in a statement the sentence "serves as a powerful reminder of farmers' legal and moral responsibility for ensuring their product is safe."

Before they were sentenced, the brothers each addressed the packed courtroom to apologize. "This is a huge tragedy for everyone involved, and we're very sorry," Eric Jensen said.

Although many farmers and ranchers across the United States had expressed outrage that the Jensens were criminally charged for the outbreak, lawyers for both sides in the case said the prosecution had led to improvements in food safety controls.