The gavel has finally dropped on Sotheby’s.

After six years of prodding from hard-charging billionaire Dan Loeb, the famed auction house has agreed to be taken private by French media titan Patrick Drahi — a deal that values Sotheby’s at $2.66 billion and ends its 31-year run as a public company.

Drahi, a noted art collector who is president of cable TV giant Altice Europe, is scooping up Sotheby’s for $57 a share, a 61-percent premium to Friday’s closing price. He’ll also take on the company’s more than $1 billion in debt, bringing the total enterprise value of the deal to $3.7 billion.

Sotheby’s shares — which trade on the New York Stock Exchange under the ticker symbol “BID” — soared 58 percent to $56.10 in early trades Monday.

That creates a windfall for Loeb who initiated his stake in 2013 when shares traded in the low $40s. Loeb’s hedge fund Third Point now holds 14.3 percent of the shares, a slug that’s now valued at $380 million.

Loeb’s run at Sotheby’s was fraught with controversy in its early days.

He attended a November 2013 auction on Manhattan’s Upper East Side not to bid on Andy Warhol’s “Silver Car Crash” — which fetched $104.5 million that night — but to stare down its soon-to-be-ex-chief executive Bill Rup­recht from a seat in the eighth row, according to a New York Magazine account.

A few weeks earlier, Loeb had sent Ruprecht a poison-pen letter, saying his “generous” pay package “invokes the long-gone era of imperial CEOs.” Sotheby’s, Loeb added, was “an old master painting in desperate need of restoration.”

In the 2014 proxy battle that followed, Loeb gained three seats on Sotheby’s board. A year later the company replaced Ruprecht with Tad Smith, a former CEO of Madison Square Garden.

In an emailed statement to The Post on Monday, Loeb said Third Point was “pleased to have played a role with our fellow board members in supporting Tad Smith and the management team responsible for this remarkable turnaround and to see Sotheby’s pass into such capable hands.”

Drahi plans to acquire Sotheby’s with his family through an entity called BidFair USA. Beyond that, his plans for Sotheby’s weren’t immediately clear.

Smith said that Sotheby’s return to private hands will give the brand more flexibility to pursue growth initiatives.

“It positions us very well for our future and I strongly believe that the company will be in excellent hands for decades to come with Patrick as our owner,” Smith said.

“I am honored that the Board of Sotheby’s has decided to recommend my offer,” Drahi said in a statement. “Sotheby’s is one of the most elegant and aspirational brands in the world.”

The deal is slated to close in the fourth quarter. At that point, the world’s two largest auction houses will be owned by French billionaires. Rival Christie’s was bought by Francois Pinault’s holding company Artemis in 1998.