President Obama had personally lobbied lawmakers in support the bill. But Democrats were not able to hold ranks.

Five Democrats joined Republicans in opposing the bill. They were Senators Max Baucus of Montana, Kay Hagan of North Carolina, Ben Nelson of Nebraska, Mark Pryor of Arkansas and Jon Tester of Montana.

And three Republicans joined the balance of Democrats in favor of it: Robert Bennett of Utah, Richard Lugar of Indiana, and Lisa Murkowski of Alaska.

Mr. Obama, in a statement, called the outcome “incredibly disappointing” and said that he would continue fighting to win approval of the bill.

“It is not only the right thing to do for talented young people who seek to serve a country they know as their own, it is the right thing for the United States of America,” Mr. Obama said. “Our nation is enriched by their talents and would benefit from the success of their efforts.”

“The Dream Act is important to our economic competitiveness, military readiness, and law enforcement efforts,” he said, adding, “It is disappointing that common sense did not prevail today but my administration will not give up.”

Newsletter Sign Up Continue reading the main story Please verify you're not a robot by clicking the box. Invalid email address. Please re-enter. You must select a newsletter to subscribe to. Sign Up You will receive emails containing news content , updates and promotions from The New York Times. You may opt-out at any time. You agree to receive occasional updates and special offers for The New York Times's products and services. Thank you for subscribing. An error has occurred. Please try again later. View all New York Times newsletters.

In a floor speech, Senator Richard J. Durbin, Democrat of Illinois, a main champion of the Dream act, urged a yes vote. “I want to make it clear to my colleagues, you won’t get many chances in the United States Senate, in the course of your career, to face clear votes on the issue of justice,” he said.

“Thousands of children in America who live in the shadows and dream of greatness,” he said. “They are children who have been raised in this country. They stand in the classrooms and pledge allegiance to our flag. They sing our ‘Star-Spangled Banner’ as our national anthem. They believe in their heart of hearts this is home. This is the only country they have ever known.”

Advertisement Continue reading the main story

At a news conference after the vote, Senator Michael Bennet, Democrat of Colorado and a former superintendent of the Denver school system, said he was thinking about all the students he knew there as he cast his vote in favor of the bill.

“Please don’t give up,” Mr. Bennet said. “Don’t be disappointed because we couldn’t get our act together.”

But opponents of the measure said it was too broad and would grant amnesty to illegal immigrants.

“As part of this legislative session there has been no serious movement to do anything that would improve the grievous situation of illegality at our border,” said Senator Jeff Sessions of Alabama, who led the opposition to the bill as the senior Republican on the Judiciary Committee. “Leaders in Washington have not only tolerated lawlessness but, in fact, our policies have encouraged it.”

Mr. Sessions added, “This bill is a law that at its fundamental core is a reward for illegal activity.”

Ms. Murkowski, in a statement, chastised Democrats for bringing the bill to the floor when it was “doomed to fail” but said that she broke with most Republicans because the legislation was important.

“I support the goal of the Dream Act which is to enable children who were brought to the United States by their parents to earn citizenship through service in the armed forces or pursuit of higher education,” Ms. Murkowski said. “ I do not believe that children are to blame for the decision of their parents to enter or remain in the United States unlawfully. The reality is that many of these children regard America as the only country they ever knew. Some were not even told that they were unlawfully in the United States until it came time for them to apply for college. America should provide these young people with the opportunity to pursue the American dream. They have much to offer America if given the chance.”

Ms. Murkowski also expressed an openness to dealing with the wider immigration issue. “ I firmly believe that Congress needs to embrace the wider immigration question, starting with securing our borders, and I plan to work with my colleagues on this issue in the new Congress,” she said.