Sen. Bernie Sanders’ stop in Berkeley Saturday was billed as a rally for Oakland Rep. Barbara Lee, but the independent Vermont senator sounded more like he was warming up his 2020 presidential campaign with a blistering attack on President Trump.

Sanders spent much of his 45-minute speech before 2,500 people at the Berkeley Community Theater ripping Trump as weak in the presence of dictators like Russian President Vladimir Putin and so ill-informed that he gets his science information from Fox News.

During his campaign in 2016, “Trump said a whole lot of things which on the surface sounded reasonable,” Sanders said, addressing the people who voted for Trump. “The only problem is that this guy is a pathological liar and it doesn’t matter what he says because the next day he is going to change his view.”

Sanders said Trump promised during his campaign that everyone would have health care. But once elected, “He lied,” Sanders. Trump supported gutting the Affordable Care Act, which would have thrown “32 million Americans off of the health care they had. Thank God that the Senate, with the vote of the late (Arizona GOP Sen.) John McCain, we were able to defeat that.”

Trump “likes to consider himself a tough guy,” Sanders said. “If you’re such a tough guy, why did you collapse in front of Vladimir Putin, who is trying to destroy American democracy?”

But Sanders said “there is something that goes even deeper in Trump that I detest.” Trump doesn’t understand that “his sacred duty as president is to bring us together, not divide us up.”

Trump “is trying to divide us up by the color of our skin, by the country we come from, by our sexual orientation, by our religion or even by our gender,” the senator said.

Sanders gave himself a retroactive pat on the back, saying that even though his 2016 presidential campaign wasn’t successful, “the ideas we were talking about” like raising the minimum wage and single-payer Medicare-for-all “that seemed so radical, so fringey, so extreme ... they are now part of the mainstream conversation.”

Lee didn’t endorse Sanders during the 2016 Democratic primary, despite holding similar progressive views. Nor did she back Hillary Clinton, fearing that she would dampen Democratic turnout by picking a side. Lee, who won 99 percent of the vote in the June primary, faces Green Party member Laura Wells in November.

Sitting on stage with Lee and Sanders but not speaking was Jovanka Beckles, the Richmond City Council member running for the open 15th Assembly District seat against fellow Democrat Buffy Wicks. Both Lee and the Sanders-inspired progressive organization Our Revolution have endorsed Beckles, but Sanders did not mention her by name Saturday. After the event, top Sanders adviser Jeff Weaver said the two “had a great conversation” but Sanders was not endorsing Beckles “at this very moment.”

Joe Garofoli is The San Francisco Chronicle’s senior political writer. Email: jgarofoli@sfchronicle.com Twitter: @joegarofoli