Regulators seized troubled First Republic Bank early Monday and sold all of its deposits and most of its assets to JPMorgan Chase Bank in a bid to head off further banking turmoil in the U.S.

San Francisco-based First Republic is the third midsize bank to fail in two months. It is the second-biggest bank failure in U.S. history, behind only Washington Mutual, which collapsed at the height of the 2008 financial crisis and was also taken over by JPMorgan.

First Republic has struggled since the March collapses of Silicon Valley Bank and Signature Bank and investors and depositors had grown increasingly worried it might not survive because of its high amount of uninsured deposits and exposure to low interest rate loans.

The Federal Deposit Insurance Corporation said early Monday that First Republic Bank’s 84 branches in eight states will reopen as branches of JPMorgan Chase Bank and depositors will have full access to all of their deposits.

Regulators worked through the weekend to find a way forward before U.S. stock markets opened. Markets in many parts of the world were closed for May 1 holidays Monday. The two markets in Asia that were open, in Tokyo and Sydney, rose.

“Our government invited us and others to step up, and we did,” said Jamie Dimon, chairman and CEO of JPMorgan Chase.

As of April 13, First Republic had approximately $229 billion in total assets and $104 billion in total deposits, the FDIC said.

At the end of last year, the Federal Reserve ranked it 14th in size among U.S. commercial banks. The FDIC estimated its deposit insurance fund would take a $13 billion hit from taking First Republic into receivership. Its rescue of Silicon Valley Bank cost the fund a record $20 billion.

Before Silicon Valley Bank failed, First Republic had a banking franchise that was the envy of most of the industry. Its clients — mostly the rich and powerful — rarely defaulted on their loans. The bank has made much of its money making low-cost loans to the wealthy, which reportedly included Meta Platforms CEO Mark Zuckerberg.

Flush with deposits from the well-heeled, First Republic saw total assets more than double from $102 billion at the end of 2019’s first quarter, when its full-time workforce was 4,600.

But the vast majority of its deposits, like those in Silicon Valley and Signature Bank, were uninsured — that is, above the $250,000 limit set by the FDIC. And that worried analysts and investors. If First Republic were to fail, its depositors might not get all their money back.

Those fears were crystalized in the bank’s recent quarterly results. First Republic experienced a modern day bank run as customers rushed to pull out more than $100 billion in deposits following the failure of Silicon Valley and Signature Bank. Unlike bank runs throughout history, First Republic’s demise was fueled by the speed of social media and digital withdrawals that can be made in seconds from a cell phone.

San Francisco-based First Republic said that it was only able to stanch the bleeding after a group of large banks stepped in to save it with $30 billion in uninsured deposits.

First Republic had been looking for a way to quickly turn itself around. The bank planned to sell off unprofitable assets, including the low interest mortgages that it provided to wealthy clients. It also announced plans to lay off up to a quarter of its workforce, which totaled about 7,200 employees in late 2022.

Investors were skeptical, and the devastating quarterly report sent them running for the exits. First Republic shares fell 75% last week and closed Friday at $3.51. Any remaining shareholders are likely to get wiped out. The shares traded at $115 on March 8, right before Silicon Valley Bank failed.

The Fed and FDIC, which regulate the banking industry along with the Office of Comptroller of the Currency, could face renewed criticism over their handling of First Republic. Both acknowledged Friday in separate reports that lax supervision had contributed to the failures of Silicon Valley Bank and Signature Bank.

For Dimon and JPMorgan, there may be a sense of déjà vu: Back in 2008, Dimon was the go-to banker for Washington to find private solutions for that banking crisis and JPMorgan acquired both Bear Stearns and Washington Mutual.

In a statement, JPMorgan portrayed the First Republic deal as beneficial both to the financial system and the company. As part of the agreement, the FDIC will share losses with JPMorgan on First Republic’s loans. JPMorgan expects the addition of First Republic to add $500 million to its net income per year, although it expects to incur $2 billion in costs integrating First Republic into its operations over the next 18 months. .