Chuck Burton/Associated Press and Pablo Martinez Monsivais/Associated Press

Warren E. Buffett comes to the rescue, again.

On Thursday, Berkshire Hathaway, run by Mr. Buffett, announced plans to invest $5 billion in Bank of America, a vote of confidence for the beleaguered financial firm.

While investors initially cheered the news bidding up bank stocks in trading this morning, the sector settled down in the afternoon as the market digested the deal.

Shares of Bank of America, which spiked more than 25 percent on Thursday, are currently at $7.55, up roughly 8 percent. Citigroup and Morgan Stanley, both up which jumped nearly 10 percent in the morning, gave back much of their early gains, too. JPMorgan Chase was off slightly in the afternoon.

The pullback reflects the continued trepidation about the industry, which is clouded by economic concerns, regulatory uncertainty, and legal liabilities.

Still, the Berkshire investment has helped allay concerns about Bank of America. Shares of the financial firm have been battered of late over fears the company lacks sufficient capital. The stock has fallen by nearly 30 percent since the beginning of August.

“I remain confident that we have the capital and liquidity we need to run our business,” Bank of America chief executive Brian Moynihan said in a statement. “At the same time, I also recognize that a large investment by Warren Buffett is a strong endorsement in our vision and our strategy.”

The Berkshire investment comes at a pivotal time for Bank of America. Its troubled mortgage division has racked up billions of dollars in legal bills, and the financial firm faces a nationwide investigation into its foreclosure practices. Last quarter, Bank of America reported an $8.8 billion loss, owing in large part to a settlement with mortgage investors.

Mr. Moynihan has taken steps to cut costs and improve its capital cushion. He put the European credit card operation up for sale and sold off the Canadian card division, making it clear non-core assets would be on the block.

Last week, the bank announced plans to cut 3,500 jobs. In a memo to employees, Mr. Moynihan said that “we owe it to our customers and our shareholders to remain competitive, efficient and manage our expenses carefully.”

But the embattled chief stopped short of raising capital, reiterating that the financial firm was on solid footing. The assertions did little to soothe investors.

Then on early Wednesday, Mr. Buffett called Mr. Moynihan to discuss a potential deal. At first, Bank of America’s chief was skeptical, saying the bank didn’t need a capital injection. But Mr. Buffett emphasized it would be a long-term investment, not a short-term fix. Over the course of the day and multiple calls, they hammered out the investment, finalizing the details late on Wednesday.

Under the terms of the deal, Berkshire will buy $5 billion of preferred stock that pay a 6 percent annual dividend, and receive warrants for 700 million shares that it can exercise over the next 10 years. Bank of America has the option to buy back the preferred shares at any time for a 5 percent premium.

It is the sort of move industry insiders had been expecting. In May, Morgan Stanley chief executive James Gorman told reporters at his firm’s annual meeting that a big name investor was bound to jump into financials, prompting the “the malaise to lift.”

“We think this news is clearly a positive for the entire group as Buffett’s investment injects confidence into the system and Bank of America in particular following its consistent erosion in recent trading,” Nomura analyst Glenn Schorr said in a research note, adding that it should help dampen volatility in the stock.

Mr. Buffett has played the role of savior before.

In the depths of the financial crisis, Berkshire Hathaway gave Goldman Sachs a $5 billion lifeline, which came with a hefty 10 percent dividend. The investment bank paid back the money earlier this year after getting the greenlight from regulators.

When shares of General Electric got hit, Mr. Buffett stepped in with a $3 billion investment. The deal also came with a 10 percent annual payout.

With Bank of America, Mr. Buffett is once again jumping in at a point of weakness. Since the beginning of the year, the bank’s shares have dropped to less than $7, from $15. Last year, it was trading at more than $19.

“Bank of America is a strong, well-led company, and I called Brian to tell him I wanted to invest in it,” Mr. Buffett said in a statement. “I am impressed with the profit-generating abilities of this franchise, and that they are acting aggressively to put their challenges behind them. Bank of America is focused on their customers and on serving them well. That’s what customers want, and that’s the company’s strategy.”

Mr. Buffett is a fan of financial companies that he thinks have a strong franchise and brand. He owns Wells Fargo, gradually upping his stake over the past year. In the latest quarter, he bought nearly 10 million shares of the lender.

He has also counted Bank of America among his past holdings. In the midst of the subprime crisis in 2007, Berkshire bought 8.7 million shares, quickly increasing the stake to 9.1 million shares.

But Mr. Buffett was critical of management at the time. He told Financial Crisis Inquiry Commission that Bank of America paid a “crazy price” to acquire Merrill Lynch in the midst of the disaster. Mr. Buffett sold off his remaining shares in Bank of America at the end of 2010.

In the video below, Susanne Craig discusses Warren E. Buffett’s decision to invest $5 billion in Bank of America.