Citigroup (C) has agreed to sell most of its asset management business to Legg Mason Inc. (LM) in exchange for Legg Mason's broker-dealer business in a $3.7 billion deal, the two companies said on Friday.

The deal will allow Citigroup, the No. 1 U.S. bank, to challenge Merrill Lynch & Co. (MER) for the top brokerage spot.

Under the deal Citigroup (search) also will get about $1.5 billion of Legg Mason (search) common and convertible preferred shares and a loan of about $550 million provided by Citigroup Corporate and Investment Banking.

Citigroup said the deal was driven by its goal to expand access to investment products, rather than creating its own asset management products. Citigroup said it would record an after-tax gain of about $1.6 billion when the deal closes.

Baltimore-based Legg Mason will gain about $437 billion of assets under management from the transaction.

The companies also forged a three-year deal that allows Citigroup to continue to offer its clients its asset management products. Legg Mason Wood Walker will be the primary domestic provider of Legg Mason's equity fund family.

These will be offered through Citigroup's Global Wealth Management businesses, Smith Barney and the Citigroup Private Bank, as well as Primerica and Citibank.

The deal, which was widely expected, does not include Citigroup's asset management business in Mexico, its retirement services business in Latin America or its interest in the CitiStreet joint venture.