Early in his speech at the Libertarian Party’s national convention on Saturday, Donald J. Trump told the party’s delegates bluntly that they should nominate him as its candidate for president. He was vigorously booed.

When the jeers died down, Mr. Trump, visibly frustrated with the rowdy reception he had received ever since taking the stage, dug in and went a step further, seeming to insult the very group that had invited him.

“Only do that if you want to win,” he said of nominating him. “If you want to lose, don’t do that. Keep getting your three percent every four years.”

The boos began anew, only louder.

Mr. Trump’s speech was without modern precedent: the presumptive nominee of a major political party giving a prime-time address at another party’s convention.

But as Mr. Trump tried to urge Libertarians to unite behind him in a shared effort to defeat President Biden, he was greeted with a hostility absent from the friendly crowds at his rallies, which overshadowed his appeals to their common cause.

Mr. Trump’s speech was delivered to an audience that included supporters wearing red MAGA hats, as well as Libertarians who were resentful of his presence at the convention where they will select their own presidential nominee.