At the White House, Mr. Trump’s top advisers worked to put the best face on a package they conceded fell short of fully funding his priorities and contained many items he would rather not have accepted.

“In order to get the defense spending, primarily, but all the rest of our priorities funded, we had to give away a lot of stuff that we didn’t want to give away” to Democrats, Mick Mulvaney, the White House budget director, told reporters during a briefing where he also highlighted funding in important areas like the military, school safety, border security and combating the opioid crisis.

“My job is to get the president’s priorities funded, which this does,” added Mr. Mulvaney, a onetime budget hawk in Congress who routinely voted against large spending packages and sidestepped a question on whether he would have done so for this week’s measure. “The president wants it to pass and wants it to be signed.”

But the bill landed with a thud among conservatives who are still on Capitol Hill. The House Freedom Caucus, whose founding members included Mr. Mulvaney, formally opposed it and sent a letter to Mr. Trump urging him to reject it.

Another founding member of the Freedom Caucus, Representative Jim Jordan, Republican of Ohio, said the spending bill was “maybe the worst bill I’ve ever seen” and recalled the 2016 election that put Republicans in full control of Washington.

“Nov. 8, 2016, I doubt that the voters were saying, ‘Put Republicans in power so that they can pass a bill that continues to fund sanctuary cities, continues to fund Planned Parenthood,’” he said. “Really? Really? That’s what the election was about?”

Among other things, the bill includes $1.6 billion for more than 90 miles of physical barriers along the border with Mexico, as well as related technology. But that sum is far short of what Mr. Trump would need to construct the expansive border wall that he promised in his campaign for president.