The House of Lords has voted to extend the planned corporate manslaughter bill to include deaths in prisons and police cells.
Peers voted by 223 to 127, defeating the government, to permit prosecutions for negligent deaths in custody in prisons or police cells.
Ex-chief inspector of prisons Lord Ramsbotham had argued for no exemption.
He highlighted several cases where people had died in custody, saying that managers at all levels would have taken greater care of their responsibilities if they knew they could face a charge of corporate manslaughter.
The Home Office said it would now consult the attorney general about the bill. It could then seek to overturn the Lords vote.