NEW YORK, Aug 29 (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 Jan. 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.

It was not immediately clear whether any of these executives or their insurers are responsible to pay any of the settlement. A Citigroup spokeswoman, Shannon Bell, declined to comment.

MARKET CAP PLUNGE

In their 547-page lawsuit, Citigroup shareholders said they ended up with huge losses as the market began to recognize the "ticking time bombs that eventually exploded back onto Citigroup's balance sheet."

Citigroup ultimately lost $27.68 billion in 2008.

The settlement covers shareholders from Feb. 26, 2007, to April 18, 2008.

By March 2009, Citigroup's market value had sunk roughly $250 billion from the start of the class period, as the bank accepted a series of federal bailouts that for a while left taxpayers owning a one-third stake.

While Citigroup has repaid the bailout money, its shares still trade at barely one-tenth their level at the end of the class period, after adjusting for a reverse stock split.

Lead plaintiffs in the shareholder lawsuit included several former employees and directors of Automated Trading Desk Inc, an electronic market making and proprietary trading company that Citigroup bought in October 2007 for about $680 million.

About 85 percent of that price was paid in Citigroup stock, and the plaintiffs received Citigroup shares as part of the transaction, according to court papers and a regulatory filing. The shares have since fallen 94 percent.

Citigroup shares closed Wednesday up 57 cents, or 1.9 percent, at $29.91 on the New York Stock Exchange.

Judge Stein also oversees bondholder and other litigation against Citigroup tied to the financial crisis.

Separately, Citigroup is trying to persuade the federal appeals court in New York to approve its $285 million settlement with the U.S. Securities and Exchange Commission of charges that it fraudulently misled investors in a sale of a $1 billion CDO.

U.S. District Judge Jed Rakoff, a colleague of Stein's, rejected that settlement last November, and Citigroup and the SEC have jointly appealed.

The case is In re: Citigroup Inc Securities Litigation, U.S. District Court, Southern District of New York, No. 07-09901.