Energy traders found some cause for celebration at the end of this long, disastrous year. California -- which has long painted energy traders as greedy villains -- declared peace Tuesday with a former major foe. The state formally ended its standoff with Williams ( WMB) by finalizing a settlement package, valued at $1.64 billion, with the Tulsa-based company. Under the settlement, California stands to save up to $1.4 billion -- or 32% -- on a $4.3 billion long-term power contract inked with Williams at the height of the state's power crisis in 2001. The settlement also calls for Williams to pay $150 million in cash over the next eight years and turn over six generating turbines, valued at $90 million, to settle lawsuits accusing the company of unfair business practices. For Williams -- a one-time giant struggling to rebuild -- the peace is worth the price. "This agreement removes significant uncertainty from our company and preserves substantial value in our California energy contracts," Williams CEO Steve Malcolm said in announcing the finalized deal on Tuesday. "The agreement is an important step toward our goal of reducing the financial risk and liquidity requirements related to our energy marketing and risk management business." Williams investors, delighted by the news, started their New Year's Eve celebration early. They sent the stock shooting to a $2.70 close, following a 19% gain for the day. The rally swept up other troubled energy companies as well. Dynegy ( DYN), which joined Williams in a close brush with bankruptcy earlier this year, jumped 16% to $1.18. Aquila ( ILA) and Mirant ( MIR) also tacked on gains of more than 5%. Even so, the entire sector has a long way to go before it can recover the billions of dollars in market capitalization it lost during this tumultuous year.