WASHINGTON — Sen. Bernie Sanders said he has ended his sputtering White House bid but will stay on the ballot in the remaining primary states to push his ideological agenda at the Democratic National Convention.

Addressing supporters in a livesteam, the self-described Democratic socialist, 78, said the decision to suspend his presidential campaign was “difficult and painful” but he understood there was no path forward.

“I wish I could give you better news but I think you know the truth and that is we are some 300 delegates behind Vice President Joe Biden and the path toward victory is virtually impossible,” he said in a broadcast to more than 100,000 people.

“While we are winning the ideological battle and winning the support of so many young people and working people across this country, I have concluded this battle will not be successful,” he added.

In an unexpected announcement, the Vermont senator said he would stay on the ballot in all upcoming primary races and continue to amass delegates that he would use to wield influence at the Democratic National Convention.

“While Vice President Joe Biden will be the nominee, we must continue to assemble as many delegates as possible where we will be able to exert significant influence over the party platform,” he said.

The party outsider spent most of his speech declaring that his campaign had won the ideological battle for universal health care, and vowed that the fight would continue.

“While this campaign is coming to an end, our movement is not,” he said.

Jay Jacobs, New York State Democratic Party chairman, described the decision as a “mistake” and said Sanders would only further divide the party.

“The nominating process is not about achieving artistic success, it’s about nominating a candidate for president,” Jacobs told The Post.

“Bernie Sanders has agreed that the nominee is going to be Joe Biden, so if he is genuine in his view that the most important thing we can do is defeat Donald Trump, then it’s incumbent on him to do everything he can to unite the Democratic Party as soon as possible around our nominee,” he added.

“Everything else is an exercise in futility and frankly will not yield anything positive for anyone. It can only work to harm the party.”

President Trump responded to the news Wednesday morning by calling for Sanders’ supporters to join the Republican Party, playing up tensions within the Democratic movement.

“Bernie Sanders is OUT! Thank you to Elizabeth Warren. If not for her, Bernie would have won almost every state on Super Tuesday!” Trump tweeted.

“This ended just like the Democrats & the DNC wanted, same as the Crooked Hillary fiasco,” he added.

The president also noted the fact Sanders would continue to collect delegates after quitting his White House bid, writing, “Wow, Bernie is unwilling to give up his delegates, and wants more of them! What’s that all about?”

In a statement, Biden congratulated Sanders for creating a progressive movement and pleaded with his young voters to join his campaign — saying he would adopt his values.

“Bernie has put his heart and soul into not only running for president, but for the causes and issues he has been dedicated to his whole life,” Biden wrote.

“As friends, Jill and I want to say to Bernie and Jane, we know how hard this is. You have put the interest of the nation — and the need to defeat Donald Trump — above all else,” he added.

“And to your supporters I make the same commitment: I see you, I hear you, and I understand the urgency of what it is we have to get done in this country. I hope you will join us. You are more than welcome. You’re needed.”

“Together we will defeat Donald Trump. And when we do that, we’ll not only do the hard work of rebuilding this nation — we’ll transform it.”