New York Community Bancorp agreed to buy Michigan’s Flagstar Bancorp Inc. in an all-stock deal with an equity value of about $2.54 billion.

Residential and commercial buildings in Detroit, Michigan,

Flagstar shareholders will receive 4.0151 shares of New York Community common stock for each Flagstar share they own, the two companies said Monday in a statement.

U.S. regional banks have been merging to grapple with low interest rates, weak loan demand and the need to boost technology spending. Pressure is coming from giants such as JPMorgan Chase & Co., which is moving into new states and spending billions annually on digital offerings. Last week, Webster Financial Corp. agreed to purchase Pearl River, New York-based Sterling Bancorp in an all-stock transaction that valued the target at $5.14 billion.

“The combination of our two companies will allow each of us to continue our transformation to a full-service commercial bank by broadening our product offerings while expanding our geographic reach with no branch overlap,” New York Community Chief Executive Officer Thomas Cangemi said in the statement. Cangemi will remain CEO of the combined company, which will be based on Long Island.

After the acquisition is completed, which is expected by the end of this year, the company will have more than $87 billion in assets and about 400 branches in nine states, as well as 87 loan-production offices in 28 states, according to the statement. New York Community is based in Westbury, New York.

Piper Sandler & Co. and Goldman Sachs Group Inc. served as financial advisers to New York Community, and Sullivan & Cromwell LLP was legal adviser. Morgan Stanley and Jefferies Financial Group Inc. acted as financial advisers to Flagstar, and Skadden, Arps, Slate, Meagher & Flom LLP was legal adviser.