(Reuters) - Citigroup Inc agreed to pay $590 million to settle a shareholder lawsuit accusing it of hiding tens of billions of dollars of toxic mortgage assets, one of the largest settlements stemming from the global financial crisis.

The agreement resolves claims that shareholders ended up with massive losses after the bank failed to take timely writedowns on collateralized debt obligations, many backed by subprime mortgages, and engaged in self-dealing transactions that hid the risks.

Citigroup denied wrongdoing in agreeing to settle. It called the accord "a significant step toward resolving our exposure to claims arising from the period of the financial crisis," and said the $590 million is covered by existing reserves.

U.S. District Judge Sidney Stein in Manhattan on Wednesday granted preliminary approval of the settlement, and scheduled a January 15, 2013 hearing to consider final approval.

Investors have sued an array of banks over their conduct leading up to and during the 2007-2008 financial crisis.

In 2010, Bank of America Corp agreed to a $601.5 million settlement related to its Countrywide mortgage unit. Last year, Wells Fargo & Co reached a $590 million accord over loans and securities from the former Wachovia Corp.

The Citigroup case began in 2008. Wednesday's accord followed mediation before retired federal judge Layn Phillips, and the gathering of nearly 40 million pages of documents, according to court papers.

"Based on the allegations and the risks we faced in establishing liability and damages, and in comparison with other securities fraud class-actions, the settlement is a very good result for the class," Ira Press, a partner at Kirby McInerney representing the shareholders, said in a phone interview.

Fourteen current and former Citigroup executives had also been sued, including Chief Executive Vikram Pandit, his predecessor Charles Prince, and former senior adviser Robert Rubin.