The bipartisan vote was 68-32 on a measure that sits atop President Barack Obama's second-term domestic agenda. Even so, the bill's prospects are highly uncertain in the Republican-controlled House, where conservatives generally oppose citizenship for immigrants living in the country unlawfully.
Spectators in galleries that overlook the Senate floor watched expectantly as senators voted one by one from their desks. Some onlookers erupted in chants of "Yes, we can" after Vice President Joe Biden announced the bill's passage.
After three weeks of debate, there was no doubt about the outcome. Fourteen Republicans joined all 52 Democrats and two independents to support the bill.
In a written statement, Obama coupled praise for the Senate's action with a plea for resolve by supporters as the House works on the issue. "Now is the time when opponents will try their hardest to pull this bipartisan effort apart so they can stop commonsense reform from becoming a reality. We cannot let that happen," said the president, who was traveling in Africa.
In the final hours of debate, members of the so-called Gang of 8, the group that drafted the measure, frequently spoke in personal terms while extolling the bill's virtues, rebutting its critics - and appealing to the House members who turn comes next.
"Do the right thing for America and for your party," said Sen. Bob Menendez, D-N.J., who said his mother emigrated to the United States from Cuba. "Find common ground. Lean away from the extremes. Opt for reason and govern with us."
Arizona Republican Sen. Jeff Flake said those seeking legal status after living in the United States illegally must "pass a background check, make good on any tax liability and pay a fee and a fine." There are other requirements before citizenship can be obtained, he noted.
He, too, spoke from personal experience, recalling time he spent as a youth working alongside family members and "undocumented migrant labor, largely from Mexico, who worked harder than we did under conditions much more difficult than we endured."
Since then, he said, "I have harbored a feeling of admiration and respect for those who have come to risk life and limb and sacrifice so much to provide a better life for themselves and their families."
The bill's opponents were unrelenting, if outnumbered.
"We will admit dramatically more people than we ever have in our country's history at a time when unemployment is high and the Congressional Budget Office has told us that average wages will go down for 12 years, that gross national product per capita will decline for 25-plus years, that unemployment will go up," said Sen. Jeff Sessions, R-Ala.
"The amnesty will occur, but the enforcement is not going to occur, and the policies for future immigration are not serving the national interest."
In the Senate, at least, the developments marked an end to years of gridlock on immigration. The shift began taking shape quickly after the 2012 presidential election, when numerous Republican leaders concluded the party must show a more welcoming face to Hispanic voters who had given Obama more than 70 percent of their support.
Even so, division among Republicans was evident as potential 2016 presidential contenders split. Sen. Marco Rubio of Florida was one of the Gang of 8, while Sens. Rand Paul of Kentucky and Ted Cruz of Texas were opposed to the bill.
The legislation's chief provisions includes numerous steps to prevent future illegal immigration - some added in a late compromise that swelled Republican support for the bill - and to check on the legal status of job applicants already living in the United States. At the same time, it offers a 13-year path to citizenship to as many as 11 million immigrants now living in the country unlawfully.
Under the deal brokered last week by Republican Sens. John Hoeven of North Dakota and Bob Corker of Tennessee and the Gang of 8, the measure requires 20,000 new Border Patrol agents, the completion of 700 miles of fencing and deployment of an array of high-tech devices along the U.S.-Mexico border.
Those living in the country illegally could gain legal status while the border security plan was being implemented, but would not be granted permanent resident green cards or citizenship.
A plan requiring businesses to check on the legal status of prospective employees would be phased in over four years.
Other provisions would expand the number of visas available for highly skilled workers relied upon by the technology industry. A separate program would be established for lower-skilled workers, and farm workers would be admitted under a temporary program. In addition, the system of legal immigration that has been in effect for decades would be changed, making family ties less of a factor and elevating the importance of education, job skills and relative youth.
With the details of the Senate bill well-known, House Speaker John Boehner said at a news conference the separate legislation the House considers will have majority support among Republicans. He also said he hopes the bill will be bipartisan, and he encouraged a group of four Democrats and three Republicans trying to forge a compromise to continue their efforts.
He offered no details on how a House bill could be both bipartisan and supported by more than half of his own rank and file, given that most of the bills that have moved through the House Judiciary Committee recently did so on party line votes over the protests of Democrats. None envisions legal status for immigrants now in the country illegally.
Boehner declined to say if there were circumstances under which he could support a pathway to citizenship, but he made clear that securing the border was a priority.
"People have to have confidence that the border is secure before anything else is really going to work. Otherwise, we repeat the mistakes of 1986," he said, referring to the last time Congress overhauled the immigration system.
Rep. Nancy Pelosi of California, the House Democratic leader, also said he favors a bipartisan approach. At the same time, she noted that Democratic principles for immigration include "secure our borders, protect our workers, unite families, a path to legalization and now citizenship for those" without legal status.
While the outcome of the Senate vote was not in doubt, supporters scrambled to maximize the vote and fell short of 70, a level they had talked of reaching. Sen. Chuck Schumer, D-N.Y., spoke with New Jersey Gov. Chris Christie on Wednesday night as he lobbied - successfully - for the vote of the state's Republican Sen. Jeff Chiesa, whom the governor appointed to his seat.
Associated Press writer Donna Cassata contributed to this report.