Terry Lundgren’s final weeks as chief executive of Macy’s are anything but peaceful.

The veteran retail boss, who is stepping down as CEO later in the quarter, is trying to avoid an ugly board shakeup that could tarnish his 13-year legacy and turn the largest US department store into a battleground littered with discarded top brass, The Post has learned.

Lundgren, who had not planned to cap his tenure with a sale, has recently become open to offers from potential friendly buyers as a proactive measure to head off any attempt to mess with the board, sources familiar with the situation said.

A partner at a private equity firm told The Post that he’d been contacted about a Macy’s sale by a real estate investor — while other industry sources close to the situation say they, too, have had similar discussions.

“We do not comment on rumors and speculation,” a Macy’s spokesperson told The Post.

The catalyst, it seems, is Jeffrey Smith’s Starboard Value, the activist New York hedge fund. Smith is said to be fed up with Macy’s poor performance since he invested in it in July 2015. Macy’s shares are down nearly 60 percent since then.

Smith is angling for seats on Macy’s board, according to several sources, who describe the situation as a looming proxy battle in advance of Macy’s annual meeting, which will likely take place in late April or May.

Starboard didn’t return calls, but it’s no secret that it has pushed Macy’s to unlock the value in its real estate holdings: Macy’s owns approximately 50 percent of its 880 stores.

Last year, Macy’s added William Lenehan, CEO of Four Corners Property Trust — a REIT — to its board.

The retailer also hired a real estate executive to negotiate with developers — and then it struck a deal with Brookfield Asset Management to redevelop about 50 Macy’s stores.

Starboard has said that Macy’s real estate is worth about $21 billion. Its market cap sits at about $9 billion.

With Macy’s annual meeting coming up and Jeff Gennette set to take over as CEO, Lundgren wants to shore up Macy’s future.

Lundgren, 65, has agreed to stay on as chairman.

“Over the past year, we have been focused and disciplined about making strategic decisions to position us to gain market share and return to growth over time,” Lundgren said in a statement last month, in which he identified 68 of 100 stores set to close this year.

“Macy’s would rather sell the company than deal with Starboard,” said a source familiar with the situation.

While Starboard is said to be eager to shake up Macy’s, a proxy battle is not a sure thing.

In addition, Lundgren’s aggressive reaction could result in Macy’s not being sold, sources cautioned.

That being said, whispers in retail circles say a list of possible acquirers would have to begin with Toronto-based Hudson’s Bay Company, which owns Saks Fifth Avenue and Lord & Taylor and bought German department store chain Galeria Kaufhof in 2015 for $2.8 billion.

HBC also controls a $14 billion real estate portfolio — including the L&T and Saks Fifth Avenue flagships.

HBC declined to comment.

In addition, a REIT teamed with a public relations firm is another possible buyer, sources said.

Our editors found this article on this site using Google and regenerated it for our readers.