SAN FRANCISCO, AUG. 26 -- Four decades after Bank of America became the first U.S. bank to provide financing to rebuild Japan's war-torn economy, nine Japanese banks agreed today to come to the stricken giant's aid by investing $130 million in its corporate parent, BankAmerica.

The agreement announced in Japan follows months of difficult negotiations. The $130 million purchase of BankAmerica notes is the first part of an overall Japanese capital infusion in the San Francisco-based bank that could total $350 million.

A bank spokesman said today that the bank understood that the Japanese have agreed among themselves to provide the funding, though he could not provide confirmation of the deal.

Observers called the agreement a small step in BankAmerica's recovery but a powerful symbol of Japan's preeminence in world financial markets.

"This is a watershed event, reminiscent in many ways of General Motors' approach to Toyota a few years back to learn better management and manufacturing methods," said William J. Barnds, president of the Japan Economic Institute of America. The Washington-based research organization is funded largely by the Japanese government.

"The numbers have been there for a year or so," Barnds added, noting that seven of the world's eight largest banks, three of the five top insurance companies and the world's biggest securities firm are all Japanese. "But an event like this really drives it home. Not too long ago, Bank of America was the world's largest bank."

Today, BankAmerica is only the third-largest banking concern in the United States -- behind New York's Citicorp and Chase Manhattan -- with assets of $96.9 billion.

In terms of profitability and other measures of performance, however, BankAmerica is at or near the bottom of any list, having been weakened by staggering loan losses, management upheaval, financial scandals and data-processing woes.

The banking firm posted a net loss of $1.07 billion in the first half of 1987 despite the profitable sale of its Charles Schwab & Co. discount stock brokerage unit. The company also lost $518 million in 1986 and $337 million in 1985 -- again, despite huge gains from the sale of such assets as its headquarters buildings in Los Angeles and San Francisco.

Still, there is a growing confidence in financial markets that the worst may be behind the company. On Monday, Merrill Lynch Capital Markets increased the size of an offering of three-year BankAmerica notes to $300 million from $250 million as a result of strong investor demand.

And BankAmerica's shareholders recently bought $8 million in newly issued common shares during the first month of a new plan that gives them a 5 percent discount.

"That comes out to $100 million a year and, in my view, is even more significant than the Japanese investment," said Donald Crowley, an analyst in San Francisco for the brokerage firm of Keefe, Bruyette & Woods. He noted that selling new shares bolstered BankAmerica's badly depleted equity capital, while selling notes does not.

Nevertheless, coming against the backdrop of rising trade tensions between the United States and Japan, BankAmerica's months-long negotiations with the Japanese assumed a high profile.

To BankAmerica's chagrin, newspapers on both sides of the Pacific chronicled pilgrimages to Tokyo for personal appeals by BankAmerica Chairman A.W. Clausen and Chief Financial Officer Frank N. Newman.

In Japan, the investment in BankAmerica was viewed as a way of appeasing U.S. anger over the continuing trade imbalance between the two nations and the sale of militarily sensitive technology to the Soviet Union by a subsidiary of Toshiba Corp.