Procter & Gamble PG is selling a big chunk of its struggling beauty business to Coty COTY for $12.5 billion in a complex transaction that will allow the world’s largest consumer products maker to focus more on its best-selling brands like Tide and Gillette, while dramatically expanding Coty’s portfolio in non-fragrance products.

The sale is the single-largest divestiture ever by P&G, which last year said it would sell off about 100 brands to focus on 70 to 80 brands, products that were responsible for about 90% of the company’s recent sales and 95% of its profit. In November, P&G announced it was selling its Duracell battery brand to Warren Buffett’s Berkshire Hathaway, a few months after it sold its Iams pet foods to Mars. There have also been other smaller transactions.

Under the terms of the deal, which were confirmed on Thursday after weeks of speculation, brands like Wella, Clairol hair coloring products, and Covergirl makeup will be split off into a separate company that will merge with Coty, a leading fragrance company that is looking to build its business outside of Europe and North American and to broaden its relatively small assortment of skincare, haircare, and make-up products. P&G shareholders will own 52% of all outstanding shares of the combined company, while Coty’s existing shareholders would own the remaining 48%. (The deal, using a mechanism known as a Reverse Morris Trust, was structured that way to avoid the higher taxes involved an outright sale.)

The beauty brands P&G is selling off have annual sales of $5.9 billion, making the division much bigger than Coty, which Wall Street analysts expect will report revenues of $4.4 billion for the fiscal year that ended in June. P&G will hang on to some beauty brands like Pantene shampoo and Olay facial moisturizes, each of which generates $1 billion a year in revenue.

P&G’s beauty business—which generated nearly one-quarter of the company’s total revenues in 2014, making it the company’s biggest unit—has been struggling for years. Net sales fell 2% in both 2014 and 2013, according to the company’s most recent annual report. And in the first three months of 2015, that worsened, with an 11% decline, the worst performance of any P&G division.

For P&G CEO A.G. Lafley, who returned to the helm two years ago to replace his own hand-picked successor, the sale continues the shrinking of a company he had aggressively built up, including the beauty division, during his first term as CEO from 2000 to 2009.

“This represents a significant step forward in the work to focus our portfolio on 10 categories and 65 brands that best leverage P&G’s core competencies,” Lafley said in a statement.