Donald Trump believes he has an unlikely ally in his quest to defeat presumptive Democratic nominee Hillary Clinton in the November election — Bernie Sanders.

The Vermont senator has stubbornly refused to bow out of the race even though Clinton has what analysts call an insurmountable lead and he and his campaign continue to bash her.

The continuing attacks have not gone unnoticed by Trump.

“Bernie Sanders has a message that’s interesting. I’m going to be taking a lot of the things that Bernie said and using them. I can re-read some of his speeches and I can get some very good material,” Trump said Wednesday on MSNBC’s “Morning Joe.”

“He said, you know, in many ways she shouldn’t be there. He said some things about her that are actually surprising, you know, that essentially she has no right to even be running and she’s got bad judgment. When he said ‘bad judgement,’ I said ‘Sound bite!’”

Team Clinton has been calling on Sanders to put a lid on the harsh attacks coming from his campaign, arguing they can only boost her GOP rivals.

But Clinton has not called for Sanders to drop out.

When she was in a similar position in 2008, she refused to quit here campaign against Barack Obama until June 7, long after it was clear he was going to win.

Clinton said at the time that her supporters were begging her to stay in the race.

Sanders insisted Wednesday he’s not going anywhere.

“We are in this campaign to win and become the Democratic nominee,” he said, telling supporters in Indiana that “unusual things can happen in politics.”

A day earlier, he testily told reporters that primary voters in California — the final primary state — had a right to have their voices heard.

“We are in this race until the last vote is cast. The people of California have a right to determine who they want to see as president of the United States and what kind of agenda they want the Democratic Party to have,” Sanders said, before launching yet another attack on Clinton, calling her a candidate who raises “millions of dollars from Wall Street and the drug companies and the fossil fuel industries.”

Veteran political consultant George Arzt said Sanders wants to make sure his issues are on the table, even though he can’t win.

“It’s over for Bernie. But he’s trying to carve a role within the party and influence the platform, and influence Hillary, which he has done. I think he’s going to go at least through California and maybe through the convention,” Arzt said.

Following her wins in four of five northeastern states, Clinton picked up 216 delegates Tuesday night.

Sanders, who won Rhode Island, gained 163, with some still to be allocated.

Clinton now has 2,164 delegates, while Sanders has 1,355. There are 2,383 needed to win.

With AP