In the opening moments of his appearance, it seemed that Mr. Trump, who was not a Boy Scout as a youth, would mostly avoid talking about the partisan clashes that have riven Washington.

But Mr. Trump, the 19th occupant of the White House to also serve as the honorary president of the Boy Scouts of America, ultimately speckled his remarks with political speech that proved startling at a Scout gathering.

He recounted the battleground states he won in last year’s election. He said Hillary Clinton “didn’t work hard” in Michigan, eliciting boos at the mention of his opponent’s name. He resurfaced his grievances with “fake news” and repeatedly doubted that the news media would report the size of the jamboree crowd. And when he landed on the second point of the Scout Law — loyalty — Mr. Trump interrupted himself to say, “We could use some more loyalty, I will tell you that.”

More than a dozen current Republican officeholders who were Scouts declined to comment or did not respond to messages on Tuesday, but a spokeswoman for Interior Secretary Ryan Zinke, who also attended the jamboree, said that he thought the speech was “very well received” and that he “appreciated the president taking the time to talk with America’s future leaders.”

Senator Luther Strange, Republican of Alabama and an Eagle Scout, said in a statement: “President Donald Trump was absolutely right when he said that the United States has no better citizens than its Boy Scouts and it’s wonderful that he has appointed so many Eagle Scouts to cabinet level positions.”

But the president’s tone and message alarmed many other people with ties to the Scouts.

Alison Deshotels, whose 11-year-old son, Cole, has been in a Cub Scout pack in Louisiana, said her son had been wary about continuing with the organization, even though he had enjoyed camping and Pinewood Derby races. But after watching the president’s speech, he said he did not want to remain involved.

“I didn’t really agree with anything he was saying,” Cole said in an interview, “and everyone in the Boy Scouts was cheering.”