Four years ago, in an attempt to save the nation’s crumbling financial system, the government played matchmaker by pushing ailing institutions into the arms of healthier rivals.

JPMorgan Chase scooped up the remnants of failed financial giant Bear Stearns at the behest of the Federal Reserve. Bank of America picked up crippled brokerage Merrill Lynch with billions in taxpayer dollars. And Wells Fargo snagged Wachovia after regulators urged the beleaguered bank to agree to a sale.

The deals were monumental. They transformed the banking landscape and created a handful of financial powerhouses, reinforcing the too-big-to-fail model. But a stream of lawsuits and towering losses have left some of these buyers with remorse.

“We’ve lost $5 billion to $10 billion on various things related to Bear Stearns now. And, yes, I put it in the unfair category,” JPMorgan chief executive Jamie Dimon said at a recent Council on Foreign Relations event. “Would I have done Bear Stearns again knowing what I know today? It’s real close.”

Dimon’s lament came a week after New York’s attorney general filed a civil lawsuit against JPMorgan, alleging Bear Stearns engaged in widespread fraud in the sale of mortgage-backed securities in 2006 and 2007. The actions occurred before JPMorgan even considered buying the foundering securities firm.

Such legal action has become commonplace as investors, shareholders, consumers and government attorneys sift through the wreckage of the financial crisis.

Consider Bank of America, which earlier this month reported a $1.6 billion charge for litigation expenses in its third-quarter earnings. The lion’s share of that expense was tied to a $2.4 billion settlement reached in September with shareholders who accused the bank of misleading them about the health of Merrill Lynch. Wells Fargo is also opening its wallet to resolve hundreds of millions of dollars worth of lawsuits with Wachovia shareholders and investors.

It is a bittersweet sequel to the dramatic rescue scenario of 2008, when the Bush administration called on the titans of Wall Street to shelter their wounded compatriots for the sake of the economy. Strong firms had their pick of multibillion-dollar corporations at fire-sale prices. Deals were sometimes pulled together over the weekend or in a single night.

“The government was intervening in an almost desperate way, so the normal acquisition procedures simply didn’t exist,” said Elizabeth Nowicki, a former attorney for the Securities and Exchange Commission who teaches at Tulane University Law School. “The big concern at the time was that the entire banking industry was going to implode . . . there was that much uncertainty seizing up the market.”

In that frantic environment, the big banks stepped in with an understanding that the long-term benefits of the acquisitions would eventually outweigh the immediate troubles.

But have they?

JPMorgan: Mixed results

As the extent of Bear Stearns’s portfolio of toxic mortgage securities came to light, the Federal Reserve scrambled in March 2008 to prevent the nation’s fifth-largest investment bank from collapsing and dragging down the financial system.

The central bank absorbed $29 billion of Bear Stearns’s mortgage securities to seal the deal with JPMorgan, which took on the remaining $370 billion in assets. The bank paid $1.5 billion for Bear Stearns, a company that at the time had a market value of more than $11 billion.

Not a bad bargain, arguably.

“It was the best risk-sharing negotiation Jamie Dimon has ever done. So for him to come back now and say it was a bad deal is just posturing,” Mark Williams, a former bank examiner who teaches finance at Boston University, said in a recent interview.

But whereas the government realized a $765 million profit from the interest earned on the vehicle created to hold the securities, JPMorgan took a $10 billion hit on the Bear Stearns portfolio.

Dimon was not made available for further comment, but during the Council event he made his doubts clear. He added that he had asked the Fed to take on more of Bear Stearns’s mortgage securities.

“I thought, ‘If you hold these things, since you guys borrow at zero percent, you’d get all of your money back.’ They’ve gotten all of their money back and are going to make a multimillion profit,” Dimon said. “I should have negotiated that whatever the extra billions are, you’re going to give it back to me to pay for litigation costs.”

Williams sees the outcome differently.

“Jamie Dimon was given a gift by the government,” he said.“Not only did JPMorgan get the fifth largest investment bank for about $1 billion in the end, but they got a Midtown Manhattan office building worth $1.2 billion.”

But Dimon stressed that the prosecution JPMorgan now faces because of Bear Stearns is a cautionary tale that no good deed goes unpunished.

Some observers agree — including Rep. Barney Frank (D-Mass.), the ranking member on the House Financial Services Committee, who talked about the JPMorgan lawsuit on CNBC last week.

“I don’t want to set the precedent that when we go to someone in the future and say, ‘Would you help us out?’ they say no,” he said. “It is fair to say that when you did this in response to pressure from the federal government, you’re not liable for the mistakes of the people that were there before.”

He said a better idea would be for prosecutors to go after individuals at the institutions who broke the law.

As for Dimon: “What I know today is if [the Fed] called me again to do something like that again, I couldn’t do it; my board wouldn’t allow me.”

He continued, “We got some great things with Bear Stearns — some businesses, their building, some great people — and some terrible things.”

Wells Fargo: Benefits

For Wells Fargo, the benefits of acquiring Wachovia have far exceeded any setbacks from litigation and losses, said Patricia Callahan, Wells’s chief administrative officer.

“There were lots of mutual benefits that we discovered in the process of putting the two companies together: technology, products, services,” said Callahan, who was involved in orchestrating the deal. “At the time of the merger, we reserved against what we expected the large losses to be and our mark was pretty accurate.”

Wachovia, which Wells bought for $15.2 billion in October 2008, came with hundreds of billions of dollars in troubled loans. Though Wells had to write down $74 billion in losses, a change in tax law at the time allowed the bank to shelter an unlimited amount of profits from taxation based on those losses.

Like other fire-sale buyers, Wells had to contend with irate Wachovia investors. It had to pony up $590 million to settle a lawsuit with bond investors, and the $75 million to resolve claims brought be former Wachovia shareholders. Wells also agreed in November 2010 to pay $100 million to Citigroup, which sued the bank for breach of contract when its bid for Wachovia was trumped.

On the other hand, Wells walked away with some 3,400 bank branches and a market capitalization that grew from $125 billion in 2008 to $183 billion as of September, according to the firm.

“This was a distressed sale, so the price was at a significant discount. Wells still had a lot of running room, even dealing with those troubled assets, to make money,” said Sheila Bair, former Federal Deposit Insurance Corp. chairman. The agency helped arrange Citigroup’s initial offer on Wachovia, but wound up supporting Wells in its bid because the bank didn’t require any government assistance to close the deal.

Banking analyst Anthony Polini of Raymond James said Wells benefitted from purchasing a bank with a better track record for underwriting loans than many of its competitors. Even though many of Wachovia’s loans went bad, he said, there was less risk of Wells having to repurchase mortgage securities than at other banks.

Bank of America: Woes

Then there’s the Bank of America purchase of Merrill Lynch — what Williams of Boston University calls “the poster child of how not to buy a company.”

Bank of America paid $50 billion, or $29 per share, for a bank that was trading at $17 a share days before the deal was announced in September 2008. The government kicked in $25 billion in taxpayer aid as an incentive, and returned months later with another $20 million in new capital to stem Merrill’s spiraling losses.

Shareholders protested. Congress held hearings. And chief executive Kenneth D. Lewis retired.

“The bank rushed the deal, spending less than 48 hours before agreeing to pay too much for a bankrupt company,” Williams said.

Williams said the haphazard acquisition resulted in a multibillion-dollar legal hangover that has stifled Bank of America’s growth. He noted that the bank was already in over its head with the $4 billion purchase of home loan lender Countrywide Financial in January 2008. Analysts estimate the final costs of that deal alone will exceed $40 billion with all of the lawsuits and write-downs of toxic mortgages. (Last week, the Justice Department filed a civil lawsuit alleging that Bank of America stripped safeguards designed to catch mortgage fraud and then peddled the loans to government-backed Fannie and Freddie—a scheme that allegedly began at Countrywide.)

Bank of America spokesperson Jerry Dubrowski declined to discuss the Countrywide purchase, but said the “acquisition of Merrill has been a tremendous benefit for our clients because we’re able to offer extensive banking services.”

Analyst Polini agrees that Bank of America’s legal woes don’t undercut the value of Merrill Lynch. The brokerage business combined with the bank’s existing investment operations have together accounted for 50 percent of Bank of America’s revenue since the acquisition, according to the company.

“The capital markets business that Merrill gives them provides a cushion for when we get a slow domestic economy, with a challenging interest-rate environment,” Polini said. “Being diversified kind of balanced some of the margin issues and the slow down in domestic lending that we saw this quarter.”

Williams acknowledges that the merger made strategic sense. But he still believes the bank could have rolled up the brokerage for half of what it paid, if management waited for Merrill to go into bankruptcy.

Investors have lost tremendous value as the bank’s stock is trading around $10 a share these days compared to $45 a share in 2009 when the Merrill deal closed, he said.

In hindsight, former FDIC chairman Bair said Merrill should have gone through bankruptcy-like restructuring, whereby the good pieces of the franchise would be spun out and either recapitalized or sold.

“From a safety and soundness standpoint,” she said, “the government should have looked more broadly at the exposure they were putting on Bank of America by forcing this transaction to go through.”

For all three banks, the long term is not yet over. All took risks, all made some gains, all have had to solve some problems. And Polini of Raymond James thinks one thing is true: As a result of the acquisitions, Wells, JPMorgan and Bank of America “are actually much safer because of their liquidity and the diversification in earnings.”

JP Morgan bought Bear Stearns in March 2008 for

 What Wells Fargo spent on Wachovia in October 2008

$50 billion
What Bank of America paid for Merrill Lynch in September 2008