Mr. Trump’s proposal paired $5.7 billion in wall funding with temporary legal protections for some immigrants and measures to make it more difficult to claim asylum in the United States. Only one Democrat, Senator Joe Manchin III of West Virginia, crossed party lines to vote for the measure. Two Republican senators, Mike Lee of Utah and Tom Cotton of Arkansas, voted against it, considering it too lenient to immigrants.

Mr. Trump’s plan was loosely modeled after an idea that was the centerpiece of quiet bipartisan talks to strike a compromise over the past several weeks to end the shutdown. Among the ideas discussed was legislation that would pair money for border security with permanent legal status for Dreamers, the immigrants brought to the United States illegally as children who stand to lose their deportation protections and work permits after Mr. Trump rescinded the Deferred Action for Childhood Arrivals program, or DACA, created by President Barack Obama in 2012.

While it included some of those components, the measure that failed on Thursday was dismissed as a nonstarter by Democratic leaders because it substantially narrowed DACA eligibility, and extended it for only three years, while making major changes to asylum law that would make it harder for migrants fleeing violence and persecution, including children from Central America, to find refuge in the United States. It would also extend three-year reprieves for those living in the United States under Temporary Protected Status — granted in times of conflict or natural disaster — who stand to be removed after Mr. Trump ended their protections.

Senator Doug Jones, Democrat of Alabama, said he had considered supporting the president’s proposal after he described it in a televised address from the White House, but found the asylum provisions “unacceptable.”

“When I saw what the president had added to the plan he announced just five days ago, particularly as it pertains to the limitations and additional hardships placed on families and children who are legitimately seeking refuge in this country from violence in their own countries, and doing so through the legal asylum process, I could not vote for it despite my consistent support for stronger border security,” Mr. Jones said in a statement.

House leaders had kept their chamber in session through the afternoon to leave room for the possibility that the Democratic measure would prevail in the Senate, and they could call a vote on it later Thursday and send it to the White House. But that never happened, and rank-and-file Democrats, many of whom had marched across the Capitol to the Senate chamber to witness the votes for themselves, spent the afternoon instead highlighting the stories of people devastated by the shutdown.

The House took separate action earlier Thursday to pass legislation to fund the Department of Homeland Security through Feb. 28, with all but five Republicans voting “no.” One freshman Democrat, Representative Alexandria Ocasio-Cortez of New York, also voted against it because it would reopen Immigration and Customs Enforcement, which she wants closed.