Home Depot Inc. agreed to buy building products distributor HD Supply Holdings Inc., reuniting the home-improvement retailer with its former subsidiary more than a decade after they split apart.

Home Depot will buy all outstanding shares for about $56 apiece, according to a statement, representing a premium of about 25% over HD Supply’s closing price on Friday. With about 156 million shares outstanding, according to a filing, the offer is valued at roughly $8.7 billion. Including net cash, the deal has an enterprise value of about $8 billion, the companies said.

The acquisition brings back together two companies that used to be under the same roof and will give Home Depot more exposure to the professional contractor side of the business. Like do-it-yourself repairs, that segment has boomed during the pandemic as Americans want to improve the homes they’re spending more time in.

One of the largest industrial distributors in North America, HD Supply provides everything from bleach, to doors and ceramic tile to about 500,000 customers from 270 branches and 44 distribution centers, according to its annual report.

HD Supply is “a good business with solid margins,” Chuck Grom, an analyst with Gordon Haskett, said in a note. The company has faced underinvestment in recent years, giving the buyer the opportunity to improve the business, he said. The tie-up could add as much as 33 cents a share to Home Depot’s earnings, Grom added.

HD Supply has been slimming down, making it “a highly attractive asset in a compelling segment of the market,” RBC analyst Scot Ciccarelli said in a note.

The deal adds to the momentum for Home Depot, which along with rival Lowe’s Cos. was deemed an essential retailer early in the pandemic and remained open even as many stores shut down for months. The HD Supply transaction, to be funded by cash on hand and debt, is expected to be completed in Home Depot’s fiscal fourth quarter, which ends Jan. 31.

Professional customers currently account for about 45% of Home Depot’s sales, and HD Supply could help it cement its leadership position, said Drew Reading, an analyst with Bloomberg Intelligence. “Though HD Supply has exposure to slower growth commercial end-markets, sales trends among pros continue to improve and may accelerate in 2021.”

Home Depot sold the construction-supply unit to a group of buyout firms — Carlyle Group LP, Bain Capital LLC and Clayton, Dubilier & Rice LLC — in 2007. That deal was initially valued at $10.3 billion including debt, but in the midst of the housing crash, it was scaled back to $8.5 billion. The chain then went public in 2013.

The announcement comes about a week after Bloomberg News reported that Lowe’s had recently approached HD Supply and that the companies were in preliminary talks, citing people familiar with the matter at the time. The report also said it was unclear whether there were discussions with other suitors. Lowe’s subsequently said it isn’t in talks and doesn’t plan to pursue a transaction.