Wells Fargo & Co., the nation's 13th-biggest bank company, announced yesterday that it plans to buy its big San Francisco rival, Crocker National Corp., in one of the largest bank mergers in U.S. history.

Wells Fargo, whose assets totaled $29.4 billion at the end of 1985, said it would pay $1.08 billion in cash and stock to Midland Bank, the British giant that bought controlling interest in Crocker in 1981 and 100 percent of the bank last May.

Crocker, with assets of $19.2 billion, has been plagued by problem loans during most of the years it has been controlled by Midland and has been a serious drain on the British bank's earnings.

The combined Wells Fargo-Crocker would have assets of nearly $49 billion. It would become the nation's 10th-biggest bank-holding company, with assets only a few hundred million dollars less than those of First Interstate Bancorp. of Los Angeles.

James F. Carter, vice president and financial analyst at Merrill Lynch, Pierce, Fenner & Smith, said the deal was surprising. "It appears the English bought at the top of the market and ended up selling at the bottom."

The $1.08 billion purchase price represents the net value of Crocker's assets -- the value of total assets minus total liabilities. Many banks are being sold today at far more than their net-asset value, which often is called book value. The sale price is essentially the amount of money Midland has invested in Crocker during the five years it has controlled or wholly owned the bank company.

U.S. banking sources said the bank company Midland is selling is far healthier than the one it purchased, in large part because the British parent bought many of Crocker's problem loans when Midland increased its stake in Crocker to 100 percent last May.

The loan purchase was designed to strengthen the California subsidiary. Midland took $3.1 billion of Crocker's foreign loans and $450 million in problem U.S. loans, many of them real estate-related. Crocker's balance sheet was essentially cleaned of foreign credits.

As a result of shedding many of its problem loans, Crocker reported a tiny, $38 million profit last year. It had a $324 million loss in 1984 and a $10 million loss in 1983. The company rolled up losses because it had to make sizable additions to reserves to cover potential bad loans -- especially to foreign countries and real-estate developers.

At the end of 1984 Crocker was the 15th-largest U.S. bank company in terms of assets. But mainly as a result of selling its loans to the British parent, it sank to the 25th-largest at the end of 1985.

U.S. bankers said the Midland investment in Crocker has been a disaster since the start. "I don't think Midland ever understood the United States, or at least the California market," said a top U.S. bank executive familiar with San Francisco and California banking. "I would not be surprised if there was covert pressure on Midland from British regulators to get rid of the Crocker albatross."

The transaction will strengthen Midland, which has performed poorly compared with its big British rivals, such as Barclays and Lloyd's Bank.

Carl E. Reichardt, chairman and chief executive of Wells Fargo, said, "We believe that this acquisition is consistent with our strategy of emphasizing domestic banking." Wells Fargo has steadily reduced its international exposure in recent years.

Reichardt said that Crocker's branch system is particularly strong in the "southern part" of California, while Wells Fargo's is stronger in the northern half.

Investors apparently agreed with Reichardt's assessment. Wells Fargo stock, which had declined $2 a share Thursday, rose 5 5/8 -- to 67 -- in trading yesterday.

Even the combined banks will pale in size to the third major San Francisco institution, BankAmerica Corp., which has assets of $118.5 billion. But BankAmerica, whose major subsidiary is Bank of America, has been hamstrung by a portfolio riddled with problem loans -- ranging from real estate and shipping to energy and international loans. BankAmerica, the nation's second-biggest banking organization, reported a 1985 loss of $337 million.

Wells Fargo, by contrast to its San Francisco competitors, has reported solid, if not spectacular, earnings in recent years. Last year, Wells Fargo had earnings of $190 million, and its profits in 1984 were $169 million.

Midland Bank Chairman Donald Barron said in a statement that the deal is expected to be completed by the middle of the year. It needs approval of Midland and Wells Fargo stockholders and regulatory agencies.

Barron said that, although Crocker now can operate profitably within the Midland group, "It is obvious that the combined market shares of Wells Fargo and Crocker will give the merged group strength in the California banking market which Crocker would be unlikely to achieve on its own, even with Midland's full backing."