Bank of America, seeking to snap this year’s stock plunge, will pay billionaire Warren Buffett $300 million a year to do what he did for Goldman Sachs during the credit crisis: bolster confidence.

The $5 billion sale of preferred equity, which initially sent the shares up 26 percent, may improve investor perceptions without meaningfully affecting the source of their concern, the bank’s capital, analysts said. The deal gives Buffett’s Berkshire Hathaway warrants — or the right to buy stock at a specific price — that could make it the lender’s largest stockholder.

Bank of America lost almost half its value on the New York Stock Exchange this year through Wednesday as investors speculated that costs linked to soured mortgages might force the company to tap public markets for more capital. The slide accelerated this month, even as chief executive Brian T. Moynihan, 51, cut jobs, sold assets and said the firm didn’t need to sell shares to meet new international capital standards.

“Concerns around Bank of America had hit a point where they were driven more by emotion than logic,” William Tanona, a UBS analyst, wrote in a research note to clients Thursday. “This should temper those emotions, at least for now.”

Bank of America’s trading floor in New York erupted in cheers and applause when the news was announced Thursday morning, said an employee who witnessed the reaction but is not authorized to speak publicly.

Buffett helped prop up Goldman Sachs in 2008 with a $5 billion investment that was repaid this year. The billionaire’s intervention helped New York-based Goldman restore market confidence after the Sept. 15, 2008, collapse of Lehman Brothers, which sent Goldman’s stock tumbling and caused its borrowing costs to jump.

The cash injection may have little effect on the Bank of America’s capital base, and the company still faces mounting legal claims linked to mortgages, many of which stem from the 2008 acquisition of Countrywide Financial.

Shares of the Charlotte-based bank gave up some of their initial gains Thursday, closing at $6.99, up 11 percent, in New York.

“He’s buying credibility,” Richard Bove, an analyst at Rochdale Securities in Lutz, Fla., said of Moynihan.

Under the deal, Omaha-based Berkshire will buy cumulative perpetual preferred stock that pays an annual dividend of 6 percent, plus warrants to buy 700 million shares at about $7.14 each, according to a statement from the companies.