Warren Buffett on Thursday unveiled one heck of a playground swap: The legendary investor said he’ll give back $4.7 billion in shares he owns in Procter & Gamble, if the consumer-products giant hands over its newly recharged Duracell battery brand.

But don’t call it a sale. The unusual maneuver requires a level of cash and savvy that few mega-dealmakers could ever offer. The best part? Both sides could end up saving billions of dollars in taxes.

It’s called a “cash-rich split-off,” and it’s 100 percent legal under the country’s tax code. It’s also become a Buffett signature, offering all the perks of a high-level business trade with none of the costly downsides of a traditional sale.

“It’s a fantastic transaction,” said Bob Willens, a New York tax expert. “Every single time you see one, you marvel at how beneficial it is.”

It works like this. Procter & Gamble will give about $1.8 billion to Duracell, America’s biggest battery maker, then trade the company for the 52 million P&G shares owned by Buffett’s Berkshire Hathaway.

The switcheroo is great for Procter & Gamble, which said last month it wanted to slim down by ditching half of its nearly 200 brands. The conglomerate gets to drop Duracell quickly and cleanly, dodge the mess and shareholder concerns of a protracted sale, and even stop paying regular dividends to Buffett’s Berkshire, which now owns a 2 percent stake in P&G.

But it’s just as sweet for the famed “Oracle of Omaha,” who will take over a big business for chump change. That wouldn’t have been the case if it was a sale. Because Buffett’s Berkshire bought its shares for about $336 million and they’re now worth about $4.7 billion, he would have had to pay a tax rate of about 38 percent on those billions of dollars in corporate gains.

Procter & Gamble will likely save just as much on its corporate taxes through “splitting off” Duracell instead of selling it. The deal, as P&G put it, “maximizes the after-tax value of the Duracell business and is tax efficient for P&G.”

The cash-rich deal is unusual — Willens can remember about 30 such trades since the ’90s — because it takes a lot of different factors to accomplish: Namely, the cash part. The “seller” must agree to pump a ton of money into something it’s getting rid of, and the “buyer” must both own shares tied to the seller and want to give them away.

But it’s a tactic Buffett has tapped several times in deals involving the Phillips 66 energy company, Whitemountain Insurance and Graham Holdings, formerly The Washington Post Co. The latter deal, which likely saved both sides $675 million in taxes, was so emblematic of Buffett’s engineering that tax expert Willens, in a report earlier this year, called it “divorce, Omaha style.”

Berkshire became one of P&G’s biggest stakeholders in 2005 when the conglomerate bought razor giant Gillette, one of Buffett’s many investments. Berkshire owns more than 80 brands, including Geico and Fruit of the Loom.

Duracell is a titan of the world’s alkaline battery industry, creating not just the AA, C and 9-volt batteries that go in your kids’ toys and TV remotes, but batteries for hearing aids, cell phones, medical devices and home security systems.

“I have always been impressed by Duracell, as a consumer and as a long-term investor in P&G and Gillette,” Buffett said in a statement. “Duracell is a leading global brand with top-quality products, and it will fit well within Berkshire Hathaway.”