HJ Heinz, owned by Warren Buffett’s Berkshire Hathaway brk.a , is to merge with Kraft Foods Group KRFT , creating a new giant in the food industry and paving the way for Heinz to return to the stock market, the two companies said Wednesday.

Heinz is to buy 51% of Kraft in a deal brokered by Berkshire and the Brazilian-based private equity company 3G. Kraft shareholders will get a $10 billion special dividend ($16.50 a share) under the deal, the rumor of which helped propel Kraft’s shares 16% in after-hours trading Tuesday. The dividend alone equates to 27% of Kraft’s market value as of the close of Tuesday’s trading.

“This is my kind of transaction, uniting two world-class organizations and delivering shareholder value,” Buffett said in the statement. “I’m excited by the opportunities for what this new combined organization will achieve.”

The new company will be called The Kraft Heinz Company and will be the third-largest food and beverage company in North America with around $28 billion in annual revenue. It will have eight brands that each generate more than $1 billion a year in sales, including Philadelphia cream cheese and Heinz’s signature tomato ketchup. Subject to regulatory approval, the deal is expected to close in the second half of this year.

The companies are targeting $1.5 billion a year in annual cost savings by the end of 2017, which is also their target for making the deal “earnings-accretive.” 3G and Berkshire will fund the special dividend entirely out of their own cash, in order to avoid any rise in Kraft’s debt level. They said they’re committed to keeping the company’s investment-grade credit rating.

3G teamed up with Buffett to acquire Ketchup maker H.J. Heinz for $23.2 billion two years ago. Buffett had said in May he expected to work with 3G on more transactions.

Berkshire and 3G said that 3G’s managing partner Alex Behring will become chairman of the new company while Bernardo Hees, currently Heinz’s chief executive, will become CEO. John Cahill, who has struggled to turn round Kraft’s fortunes as CEO, will become vice-chairman and will head a newly-formed operations and strategy committee.

Packaged-food makers such as Kraft are battling sluggish demand as consumers shift to products perceived to be healthier.

Kraft has overhauled its senior management over the past few months and has said it will develop products to meet changing consumer preferences.

Speaking on CNBC Wednesday morning, Buffett said he’s upbeat about the future for Kraft’s brands, which include Philadelphia cream cheese and Oscar Mayer meats.

Buffett said he’s “willing to bet a lot of money” on the current management team, adding that the products Kraft makes appeal to many consumers. “This is not a static operation,” he said, noting that a handful of new products will be coming out in the coming year.

—Reuters contributed to this report.

Read more from Fortune on the Heinz-Kraft deal:

Here’s what happens when 3G Capital buys your company

6 small bites on the giant Heinz/Kraft merger

Kraft is a big mess. Here’s how the Heinz deal might help

Junk food: A winning strategy for the new Kraft Heinz?