Warren Buffett showed again that his name and money is enough to give a struggling company instant credibility in the market. But the legendary investor also demonstrated his canny command of that reputation means that such deals can immediately generate profits.

Bank of America Corp on Thursday said Buffett's Berkshire Hathaway would invest $5 billion in the bank, the largest by assets in the United States.

Buffett, known for his grand gestures and his calls to buy American assets, may have looked like he was a lender of last resort -- or at least a lender of last credible resort -- but he was also turning a hefty profit, experts said.

He's not doing it out of charitable motive or even out of a concern for the safety and soundness of the financial system, said Robert Reich, who served in three U.S. governments, most recently as secretary of labor under President Bill Clinton.

He's got a lot of shareholders and they depend upon him to maximize the value of their investments, said Reich, now a public policy professor at the University of California Berkeley.

Bank of America's shares had been sinking on worries that it might need a massive injection of capital, a major concern given the importance of the bank to the American financial system.

Buffett is buying preferred shares and receiving warrants. The deal guarantees Berkshire $300 million a year in dividends and offers a chance for huge returns if the stock climbs.

At one point on Thursday the shares climbed 25.8 percent. By the close those gains were trimmed back to 9.4 percent, but Berkshire was still sitting on a paper profit of nearly $3 billion.

Berkshire Class A shares closed down 2.8 percent at $103,415 on Thursday, while its Class B shares closed 2.5 percent lower at $68.99.

'NOT ALTRUISTIC'

In many ways, Buffett has perfected the art of swooping in at the last minute when he thinks an American icon is undervalued and has hit troubled times.

Back in the late 1980s, Buffett purchased a stake in Salomon Brothers and even temporarily stepped in as chairman after a trading scandal threatened the company.

The investment was ultimately profitable but for a while looked like it could turn into a bankruptcy, the inside story of which was described in an October 1997 Fortune magazine article.

Since then, Buffett has continued to profit on financial stocks.

During the 2008 financial crisis, he invested $5 billion in Goldman Sachs Group Inc and $3 billion in General Electric Co.

Buffet got a 10 percent dividend on each of those investments.

The investment in Goldman famously earned him the equivalent of more than $15 in dividends each second, or $500 million per year.

In March, Goldman said it would buy back its preferred stock from Buffett at the agreed upon 10 percent premium.

GE, which also has an agreement with Buffett that includes a 10 percent redemption premium, plans to buy back its shares in October. By then, dividends will have topped $900 million.

In the Bank of America deal, the annual dividend may only be 6 percent, but that isn't bad at a time when an investor can only get a 2.2 percent yield on a 10-year Treasury note or next to nothing from a bank deposit or money-market fund.

Mr. Buffett is a very shrewd investor and is not altruistic at all. The terms he gets are very favorable to him, said Richard Bernstein, former chief investment strategist at Merrill Lynch and current CEO of investment advisory Richard Bernstein Advisors.

Too bad the government didn't do the same with TARP. Taxpayers got ripped off in comparison to the terms Mr. Buffett got, Bernstein said in an e-mail referencing the U.S. government's bank rescue plan, the Troubled Asset Relief Program, which was introduced in 2008.

Buffett has shown he won't invest in a storied name just because it is in trouble, though. He turned down pleas from Lehman Brothers then-CEO Dick Fuld for an injection of capital before it collapsed.

POWERFUL PLAYER

Financial experts said Buffett at times may almost seem as powerful a player in financial markets as the government or the Federal Reserve.

Warren is not the Fed and is not a branch of government, but he comes about as close as any private individual can come to having the power of public policy, Reich said.

Mark Zandi, Moody's Analytics' chief economist and former adviser to 2008 Republican presidential candidate John McCain, said a lot of it has to do with confidence.

Our most serious economic problem at this point in time is a lack of confidence. We've lost faith in our economy and I think (Buffett) is working really hard to shore up confidence.

(Editing by Vinu Pilakkott)