Throw the book at him!

The $52 million deal to redevelop the Brooklyn Heights library into a luxury condo tower, which City Hall awarded to a de Blasio pal who offered less money for the city-owned land than two other bidders, has attracted the attention of federal and city prosecutors, The Post has learned.

The joint probe comes three months after The Post revealed the sweetheart scheme and marks the seventh pay-to-play scandal engulfing the de Blasio administration.

Mayor de Blasio’s latest imbroglio has investigators questioning why the city chose Hudson Cos. to buy the Brooklyn Public Library branch on Clinton Street and build a 36-story condo on top of it despite submitting a bid that was $6 million less than a competitor’s.

The offices of US Attorney Preet Bharara and Manhattan District Attorney Cyrus Vance sent subpoenas to several of the 14 developers that bid on the project, sources familiar with the investigation said.

One of the subpoenas went to Toll Brothers City Living New York President David Von Spreckelsen, a source said. Toll Brothers offered $1 million more than Hudson, the sources said.

Hudson President David Kramer is “one of many people being looked at” but has not been subpoenaed, the sources said.

Federal and city prosecutors, and Von Spreckelsen and Kramer all declined to comment.

Hoping to raise money to refurbish its system, the Brooklyn Public Library approached the city to draw up a request for proposals for the development of the site.

The city and library jointly released the RFP in June 2013.

The city Economic Development Corp. vetted the bids on behalf of the library.

Kramer proposed a 30-story residential skyscraper — with 114 units of affordable housing sited two miles away. The plan included space for the library on the ground floor and $40 million of the $52 million bid to spruce up other branches. He also planned to relocate the library to a space on Remsen Street in July 2016 for the four-year construction period.

At least two competing developers not only offered to pay the library more money, but several proposed to build affordable units on the site.

Brooklyn-based Second Development Services offered the library $6 million more than did Hudson and 117 affordable units.

One competing bidder described the process as rigged to benefit de Blasio’s friends.

“It’s going to be hard to explain to a federal prosecutor why Toll Brothers, a large firm, was outbid by a smaller bidder,” the source said.

Kramer not only lavished cash into the mayor’s campaign coffers, he pressed his case in meetings with Deputy Mayor Alicia Glenn in early 2014.

“Kramer was telling people at the time, ‘Whatever we need to do, we’re going to win this,’ ” said one real-estate source familiar with the bid process.

A friend of the mayor for more than a decade, Kramer and his wife have given $9,125 to de Blasio’s political campaigns since 2007. De Blasio has refunded $6,325 of that money without giving an explanation on city campaign filings.

De Blasio kept another $4,850 that came from Hudson employees, records show.

Kramer and his project architect, Jonathan Marvel, also hosted fund-raisers for de Blasio’s mayoral campaign, including an October 2013 soirée for which Marvel invited the city’s biggest developers.

Six weeks after de Blasio was sworn in, Hudson coughed up $5,000 to the Campaign for One New York, a charity promoting the mayor’s agenda. Marvel Architects added $2,000 in June 2015.

Toll Brothers also has given CONY two $25,000 donations.

The city picked Hudson and Toll Brothers as the two finalists in the summer of 2014 before choosing Hudson in September of that year. Demolition and construction is slated to begin this fall.

A de Blasio spokesman said the RFP process for the library “followed a strict protocol” and that Hudson Companies won the contract “meritoriously, as its bid provided the best overall package for the library . . . including the most affordable housing.”

Additional reporting by Jamie Schram