Amazon is shelling out $1.15 billion in cash to acquire the former Lord & Taylor flagship in Midtown Manhattan, The Post has learned.

The Fifth Avenue landmark, which spans 11 stories and 660,000 square feet, will serve as Amazon’s New York City headquarters, housing several thousand employees in the coming years, a source close to the situation said.

That’s a switch from the plan two years ago, when the former department-store space had been leased by WeWork to become the office-sharing startup’s own headquarters. WeWork’s plans fell apart last fall, when the company became engulfed in a slew of scandals that derailed its bid to go public.

Indeed, the lion’s share of the deal consists of Amazon paying off $750 million in construction loans taken out for WeWork’s lavish renovation of the space, sources said. The remainder consists of more than $350 million in equity for the building’s current owners.

WeWork has waived any economic interest in the building in exchange for getting out of the lease, and co-founder Adam Neumann will not make any money on the deal, sources said.

Amazon is paying effectively more than $2,000 per square foot for the midtown property, according to a source.

Amazon had been in on-again, off-again talks for the past several months with the building’s owners, which include a joint venture between WeWork’s parent company and the hedge fund Rhone Capital; and Hudson’s Bay Co., the owner of Saks Fifth Avenue, sources said. The consortium bought the building for $850 million in late 2017.

Over the past 60 days, the talks heated up as Amazon saw rivals pursuing their own Big Apple deals. While Facebook has been in talks to lease the 700,000-square-foot Farley Building, Apple last month inked a lease on 220,000 square feet at 11 Penn Plaza.

“Jeff Bezos toured three properties in Manhattan at Hudson Yards, the Farley and the Lord & Taylor property, and he chose Fifth Avenue,” a source with knowledge of the deal told The Post, although another source denied Bezos visited the properties personally.

The building is the latest space to get scooped up by Amazon after the Seattle-based e-tailing giant scrapped plans a year ago to build a second headquarters in New York City.

In December, Amazon leased 335,000 square feet in Hudson Yards, with plans to house 1,500 employees there. Amazon also has reportedly been in talks to lease 400,000 square feet of additional space at 460 W. 34th St.

Nevertheless, the recent deals are a far cry from the campus Amazon had envisioned building in Long Island City, which would have spanned more than 4 million square feet and housed 25,000 employees.

Amazon has scrapped plans for the so-called HQ2 headquarters in Queens amid a backlash over incentives it was getting from local politicians.

Amazon and WeWork didn’t immediately respond to requests for comment.