Music mogul David Geffen is scooping up expat socialite Denise Rich’s Upper East Side penthouse apartment for $54 million, Page Six can exclusively report.

The price tag for the 12,000-square-foot duplex is well below the $65 million that Rich — who’s just given up her US passport for tax purposes — was asking.

Geffen will take up to two years, sources say, to fully renovate the palatial seven-bedroom digs before moving in.

The DreamWorks co-founder already has an apartment in the same Fifth Avenue building, just beneath the one he’s bought from Rich. But, sources tell us, he won’t be combining the two apartments, and will sell off his old one when his extensive renovations are done.

The Corcoran Group had the listing on Rich’s megapad with 11 baths and three kitchens, plus a grand salon, formal dining room, media room, billiards room, full gym and library with fireplace.

It also houses Rich’s full recording studio, which Geffen plans on gutting, we’re told.

The apartment went on the market in January and was eyed by buyers including the prime minister of Qatar, Sheik Hamad bin Jassim bin Jaber al-Thani. The sheik was shunned, however, by co-op boards because he rolls deep with two wives, 15 children and a gun-toting security detail, The Post reported.

Before Geffen sealed the deal for Rich’s place, rumors recently surfaced that a rich Russian was interested but couldn’t get past the board. Rich’s reps shot down the speculation.

Ironically, Geffen and Rich once had a flap as neighbors in the building, when Geffen reportedly threatened to take Rich to court after her Jacuzzi overflowed, damaging art and clothing in his apartment below. The pair eventually settled.

Rich just renounced her American citizenship, apparently to stop paying US taxes. But under US law, she’ll have to pay a stiff “exit tax” on the fair-market value of her worldwide assets, including the apartment’s sale.