Legg Mason Inc., the money manager that has struggled with five years of net withdrawals, posted a profit as long-term funds won their first net deposits since 2007 and rising equity markets lifted assets.

Net income was $47.8 million, or 38 cents a share, in the fiscal first quarter ended June 30, compared with a loss of $9.5 million, or 7 cents a share, a year earlier, the Baltimore-based firm said today in a statement. Earnings included a cost of $26 million related to opening a closed-end fund. Legg Mason beat the 35 cent-a-share average estimate of nine analysts in a Bloomberg survey, sending the shares up the most in six months.

Legg Mason had its first net deposits in more than five years into long-term funds, which exclude short-dated assets such as money-market accounts, as its bond funds attracted $900 million in new money. Joseph A. Sullivan, 55, named chief executive officer in February, has vowed to stem withdrawals by focusing on Legg Mason’s product lineup and improving performance.

Fixed income inflows “represent a continued improvement quarter over quarter,” Daniel Fannon, a San Francisco-based analyst at Jefferies & Co., wrote today in a note to clients. “Performance fees and fund revenues were strong.”

Revenue Increase

Legg Mason rose as much as 5.4 percent, the biggest intraday gain since Jan. 10, and advanced 4.8 percent to $35.66 at 10:51 a.m. in New York. The shares gained 32 percent this year through yesterday compared with the 29 percent gain in the Standard & Poor’s 20-member index of custody banks and asset managers. The shares have fallen about 75 percent from their peak of $136.40 in February 2006.

Legg Mason, whose assets peaked at $1 trillion in 2007 as investors flocked to funds managed by top-ranked managers such as Bill Miller, oversaw $644.5 billion at the end of June, a 2 percent increase from a year earlier and a 3 percent decrease from the previous quarter. Investors pulled $700 million from equities and $8.7 billion from Legg Mason’s money-market funds in the quarter.

Revenue increased 6.3 percent to $670.4 million compared with a year earlier on higher investment-management and performance fees. Investment fees, which are generally helped by higher assets under management, rose 4.7 percent to $191 million, and performance fees, earned by funds for beating certain benchmarks, more than doubled to $22 million.

Bond Assets

The firm’s stock assets rose 8.8 percent to $164.4 billion in the year ended June 30, and increased 1.6 percent from the prior quarter. Bond assets, managed mostly by Western Asset Management Co., fell 2.7 percent to $351 billion in the past 12 months, and 3.9 percent compared with the previous three months.

“When you have a diversified portfolio, you don’t have feast or famine, so we’re trying to smooth out the booms and busts,” Sullivan said in a telephone interview today. “We want to grow our fixed income, but we want to grow our equity, non- U.S. equity and alternative businesses faster to further balance and diversify.”

Money managers, which earn fees based on the assets that they manage for clients, traditionally benefit from rising stock markets and investor deposits into higher-fee equity funds. The U.S. benchmark Standard & Poor’s 500 Index increased 18 percent in the year ended June 30, and 2.4 percent in the second quarter. The MSCI All Country World Index of global stocks rose 14 percent in the 12 months through June and fell 1.2 percent in the second quarter.

Market Slump

Stock and bond markets worldwide slumped in June amid concern that the Federal Reserve may reduce its bond purchases. Investors pulled about $60 billion from U.S. bond funds, the biggest monthly redemptions in records going back to 1961, according to estimates from the Investment Company Institute. Equity funds industrywide gathered a net $260 million.