In the years leading up to this month’s sale the Devils were at war with their contractors over millions of dollars in unpaid bills and promises not kept to an array of groups from janitorial services to a longtime Newark nut company The Star-Ledger has learned.

Essex County court records offer a behind-the-scenes glimpse at the stark financial pressures the team’s parent company faced as it weighed offers for a franchise that arrived in Newark in 2005 with a promise to anchor the revitalization of a struggling city.

During that period the Devils incurred hundreds of millions of dollars in debt leading to last week’s reported $320 million sale to investors Joshua Harris and David Blitzer.

Though the final chapter in team owner Jeff Vanderbeek’s nine-year stewardship of the Stanley Cup-winning franchise was written last week the storyline was being drafted for several years court records show.

Angry contractors upset to find themselves on the hook for millions laid out for services essential to the Prudential Center’s day-to-day operations turned to the courts to get the Devils to pay up.

The company that cleans the Prudential Center got dragged into litigation as did the team’s primary food and beverage provider. Things got so bad that the team accused the concession company of refusing to feed Devils players during the fall of 2011. And the team accused the cleanup crews of finishing off beers patrons left behind.

And others like Jeff Braverman the co-owner of the family-run Newark Nut Co. a 75-year-old city landmark walked away feeling betrayed.

“It was just a terrible situation” Braverman said.

Newark Nut was one of the last companies to agree to move out of the Mulberry Mall to make way for the Prudential Center. In return for the company relocating to Cranford the Devils agreed to let it serve as the sole supplier of nuts in the arena.