KKR is cashing in on a mega-buyout it made more than a decade ago. And in the process, the firm has avoided another tough result after a series of pre-financial crisis private equity deals went sour.

Fiserv has agreed to purchase KKR-backed, publicly traded First Data in a $22 billion stock deal that will combine the fintech companies. As part of the agreement, First Data shareholders will receive .303 Fiserv shares for each share of First Data common stock they hold. That values First Data's common stock at $22.74, marking a 29% premium to the company's weighted stock average over the past five days.

The move comes in an industry that's been consolidating, most notably when Vantiv acquired WorldPay for some $10 billion in 2017. And this particular payments deal, which is among the biggest financial mergers of the decade, is a significant one: By combining Fiserv, which sells its software to financial institutions such as banks and credit unions, and First Data, which offers point-of-sale merchant processing services to retailers, two companies that operate at opposite ends of the sales process will join forces.

Upon the deal's closing, KKR's ownership stake in First Data will drop from 39% to 16%. Fiserv stockholders will own 57.5% of the new business, with First Data shareholders retaining the remaining 42.5%. The deal is expected to generate some $900 million in run-cost savings and $500 million in revenue synergies, with Fiserv expected to refinance First Data's roughly $17 billion debt load. Fiserv CEO Jeffery Yabuki will also lead the new entity, which will operate under the Fiserv brand, while First Data CEO Frank Bisignano will serve as president and COO.

KKR originally acquired First Data in 2007 for about $29 billion in one of the largest leveraged buyouts of all time. The timing was not ideal, as the financial crisis came soon after. The firm eventually took the Atlanta-based credit card payment processor public in 2015, raising some $2.6 billion after selling 160 million shares at $16 apieceto give it a roughly $14 billion market cap. However, KKR didn't sell any of its stock in the exit, per The Wall Street Journal, and the business at times weighed down the firm's overall profitability in the ensuing years,before it began unloading shares through secondary offerings in 2017.

But all in all, KKR execs can't be too upset about their First Data investment, especially if they compare it to how the firm's other pre-crisis mega-buyouts fared. KKR teamed with TPG Capital and Goldman Sachs in 2007 to buy Texas utility company Energy Future Holdings for $48 billion. The business eventually went bankrupt in 2014 in what became widely known as one of the biggest leveraged buyout flops ever.

And its deal with Bain Capital and Vornado Realty Trust to take Toys R Us private in 2005 for $6.6 billion had a similar result. The children's toys retailer went bankrupt in late 2017 before liquidating altogether last year. Bain Capital and KKR ultimately set up a $20 million fund to pay off the severance owed to the company's former employees.

The news of this latest deal sent the stock price of KKR (NYSE: KKR) up more than 5%, ending the day at $22.25 per share. Shares of First Data (NYSE: FDC) saw an even larger boost, jumping more than 21%, while shares of Fiserv (NASDAQ: FISV) fell about 3.3%.