Mr. Barrasso, who is seeking his third term in the Senate, has managed to find a way to coexist in Mr. Trump’s Republican Party, even though his political style and approach to governing could not be more different from the president’s.

Mr. Barrasso, a nose-to-the-grindstone tactical politician with medical training from Georgetown and Yale, is deeply involved in his party’s efforts to shape a legislative agenda as chair of the Senate’s Republican Policy Committee. He was never as outwardly critical of Mr. Trump as some of his Senate colleagues were, either during the 2016 election or after the president took office. He has occasionally broken with Mr. Trump, for example by calling on him to release his tax returns and opposing, albeit gently, the administration’s plan to separate immigrant children from their parents.

Representative Liz Cheney, the state’s lone House member and a Republican, was also renominated on Tuesday.

In the other contest unfolding on Tuesday, in Alaska, voters were picking candidates to challenge Gov. Bill Walker, an independent who has disappointed members of both major parties as the state grapples with slow economic growth and rising violent crime. The Democratic primary was uncontested, with only Mark Begich, a former United States senator, running. On the Republican side, Mike Dunleavy, a former state senator, won the party’s nomination for governor.