Mayor de Blasio waited six and a half months to endorse Hillary Clinton for president in 2015 — all while poking fun at her behind the scenes, according to newly released emails.

“Do you get the feeling she needs to start learning to use short declarative sentences???” de Blasio emailed outside adviser John Del Cecato on June 19, 2015, about an interview where Clinton spoke about her position on the Trans-Pacific Partnership. “She’s even worse than me.”

Five days later, after a Senate vote cleared another hurdle in President Obama’s push for the controversial TPP trade agreement, de Blasio predicted a wishy-washy Clinton response.

“I also think Hillary will say she’s against it and then will let the Congress pass it, and she’ll hope to implement it,” he wrote on June 24 in another email to Del Cecato and aides. “She’ll want to have her cake and eat it too.”

In another email July 3, 2015, de Blasio passed along an opinion piece titled “Clinton and Obama are on the wrong side of history,” saying “Thought you’d like this.”

De Blasio’s blunt remarks were plucked from over 14,000 pages of emails dumped by City Hall on Thursday — under court order in response to a Freedom of Information suit filed by The Post and NY1 — when the nation was focused on the Brett Kavanaugh hearing.

De Blasio fought to keep his official communication with outside political strategists like Del Cecato secret by arguing they’re “agents of the city,” but this claim was rejected by judges.

The emails show de Blasio using the trade deal as an excuse to withhold his endorsement of Clinton.

When House Democrats initially rejected the trade bill on June 12, the mayor told Del Cecato, his wife and an aide in an email: “now I guess Hillary is brilliant for hiding” on the issue.

A few months later, he gleefully responded to news that Clinton “will definitely have a position” on TPP.

“Let us pray!” de Blasio wrote on Oct. 6.

De Blasio also praised Clinton’s opponent Sen. Bernie Sanders later that day, emailing that the liberal Vermont pol’s praise was “helpful” and “adds momentum.”

But the next day, Clinton came out against TPP, and on Oct. 11, her campaign started coordinating with de Blasio on how to roll out his endorsement.

The mayor finally backed her on Oct. 30, once he returned from a trip to Israel, and after services for slain police officer Randolph Holder and the anniversary of Hurricane Sandy.

Clinton included his endorsement in a long list of other mayors backing her, quoting him fourth on an official release, after mayors from Chicago, Philadelphia and Houston.

De Blasio’s cringe-worthy hesitation to endorse Clinton was part of an apparent attempt to boost his own relevancy in the presidential election.

A de Blasio spokesman had no immediate comment.