A California nursing home operator has agreed to pay $50 million to settle a lawsuit that threatened to bankrupt the company after a jury ordered it to pay $677 million for failing to provide enough nurses and staff.

Orange County-based Skilled Healthcare Group Inc. announced the settlement late Tuesday. The money will go to the roughly 32,000 patients covered by the class action lawsuit. It will also cover attorney fees.