Wells Fargo & Co on Wednesday posted a $3.05 billion first-quarter profit, in line with its prior forecast, as a surge in mortgage banking as well as benefits from the purchase of Wachovia Corp offset rising credit losses.

Excluding the payment of preferred stock dividends, net income for the fourth-largest U.S. bank was $2.38 billion, or 56 cents per share, compared with a profit of $2 billion, or 60 cents, a year earlier. Wells Fargo's shares outstanding increased because of the Wachovia acquisition.

Revenue totaled $21.02 billion, above the $20 billion that Wells Fargo had forecast.

Analysts on average forecast profit of 55 cents per share on revenue of $19.91 billion, according to Reuters Estimates. The bank's largest shareholder is Warren Buffett's Berkshire Hathaway Inc .

Wells Fargo returned to profit after losing money in the fourth quarter, its first loss in seven years.

Shares of the bank soared 32 percent on April 9 after it issued preliminary results showing a profit more than double what analysts were at the time expecting.

The bank had booked significant losses when at the end of 2008 it paid $12.5 billion for Wachovia, which had been felled by mortgage losses at the former Golden West Financial Corp.

Shares of Wells Fargo closed Tuesday at $18.81 on the New York Stock Exchange. Through Tuesday, the shares had fallen 36 percent this year, compared with a 23 percent decline in the KBW Bank Index <.BKX>.

(Reporting by Jonathan Stempel, editing by Dave Zimmrman)