Undeterred by questions of delegate math or political momentum, Senator Bernie Sanders brushed off suggestions on Friday that his campaign had no way forward and forcefully made the case that he was the Democratic candidate better suited to defeat Donald J. Trump in a general election.

Mr. Sanders blitzed through Idaho, Utah and Arizona ahead of crucial nominating contests in those states on Tuesday. Facing a deep deficit in the race for delegates after losses in five states this week, he continued to hammer away at his core messages on campaign finance and Wall Street reform while trying to seize the mantle of electability from Hillary Clinton.

“Let me say a word to you about my good friend Donald Trump,” Mr. Sanders said at a rally before more than 3,000 people at a high school gym in Idaho Falls. “Just kidding, he’s not my good friend. In fact, I never even went to one of his weddings.”

Despite the veiled jab at Mrs. Clinton, who did attend Mr. Trump’s third wedding, Mr. Sanders directed most of his fire at the leading Republican candidate. He said he was “making an exception” to his promise not to campaign negatively, saying it was a necessary evil because of the gravity of Mr. Trump’s rise.