Hillary Clinton and Bernie Sanders debating in Brooklyn in April 2016.

Hillary Clinton torches her Democratic primary rival Bernie Sanders and blames him in part for her defeat in an excerpt from her upcoming memoir about the 2016 race.

In a passage from “What Happened,” Clinton accuses Sanders and the so-called “Bernie Bros” sect of his supporters for slinging mud on her that stuck through the general campaign — and, she says, buried her bid for the White House.

"Because we agreed on so much, Bernie couldn’t make an argument against me ... so he had to resort to innuendo and impugning my character,” Clinton writes about the Vermont senator.

“When I finally challenged Bernie during a debate to name a single time I changed a position or a vote because of a financial contribution, he couldn’t come up with anything. Nonetheless, his attacks caused lasting damage, making it harder to unify progressives in the general election and paving the way for Trump’s ‘Crooked Hillary' campaign.”

Clinton also says the treatment she saw from Sanders’ supporters was “ugly and more than a little sexist.”

The former secretary of state blames Sanders — an independent who ran on the Democratic ticket — for disrupting the party’s standing by the time Clinton finally clinched the presidential nomination.

“He didn’t get into the race to make sure a Democrat won the White House, he got in to disrupt the Democratic Party,” she writes.

“He also engaged a lot of young people in the political process for the first time, which is extremely important. But I think he was fundamentally wrong about the Democratic Party...I am proud to be a Democrat and I wish Bernie were, too.”