His supporters leapt to their feet and gave him a standing ovation. He thanked Wyoming voters, but said with a smile, “There are probably more people in this room than there are in Wyoming.”

It was the only contest of the day for the Democrats. In Colorado, Senator Ted Cruz of Texas swept all of the state’s delegate elections, which ended on Saturday at the state Republican convention when he picked up the remaining 13, bringing his total there to 34.

Mr. Cruz, the only candidate to speak at the convention, received a rousing reception.

“The real question is: Do you understand the principles and values that made America great in the first place?” he said, taking a jab at his rival, Donald J. Trump, whose organization struggled with the most basic tasks in Colorado, such as printing the right delegate names next to the right ballot numbers on the lists of preferred candidates that Trump volunteers distributed on Saturday.

Like Mr. Sanders, Mr. Cruz still trails the front-runner in his race, Mr. Trump. And the campaign now moves to territory likely to be far more favorable to Mr. Trump.

Though Mr. Sanders was favored in the Wyoming Democratic race, Mrs. Clinton had endorsements from more elected officials, as she does in most states, and the state’s four superdelegates are supporting her. In 2008, she lost to Barack Obama in Wyoming by 24 percentage points.