The Senate passed the immigration reform bill 68 to 32 on Thursday afternoon. (Sandi Moynihan/The Washington Post)

The contentious bipartisan effort to overhaul the nation’s immigration laws achieved a decisive victory Thursday when the Senate approved legislation that would allow millions of illegal immigrants the chance to live legally in the United States and to eventually become U.S. citizens.

The 1,200-page bill, which now faces a stern test in the Republican-controlled House, carries a $50 billion price tag. It would double the number of U.S. Border Patrol agents along the southern border and require the construction of 700 miles of fencing there. It also would place new burdens on employers, who would be required to check the legal status of all job applicants using the government’s E-Verify system.

Senators approved the plan 68 to 32, capping more than six months of negotiations that began behind closed doors and concluded with almost a month of debate on the Senate floor. Fourteen Republicans voted with every member of the Senate Democratic caucus to approve the bill — an impressive bipartisan margin in a chamber that has become sharply partisan.

“Before the American people give up on the Congress, look at what we achieved today in a bipartisan fashion,” said Sen. Richard J. Durbin (D-Ill.), a key member of a group of Democrats and Republicans who wrote the bill.

But the path ahead is likely to be increasingly acrimonious because the bill is now in the hands of the House, where intense GOP opposition threatens to kill it outright.

What happens next with the immigration bill?

House Speaker John A. Boehner (R-Ohio) on Thursday laid down stern conditions for what kind of immigration bill he would allow the House to vote on, and it was not the one that came of out the Senate.

Boehner said that any bill would need majority support among his GOP colleagues before it could get a vote in the House. “For any legislation, including a conference report, to pass the House, it’s going to have to be a bill that has the support of the majority of our members,” he said. Recent history suggests that assembling such a majority will be difficult to achieve.

If the Senate legislation were to be signed into law, it would set millions of eligible immigrants on a 13-year course toward achieving permanent residency status or U.S. citizenship, but it would also require them to pay thousands of dollars in fines and back taxes.

Before those things could happen, however, the federal government would be required to spend tens of billions of dollars fortifying the U.S. border with Mexico with thousands of new federal agents as well as radar and unmanned aerial drones to track illegal border crossings. The Department of Homeland Security also would have to establish a biometric tracking system at the nation’s 30 largest airports.

Rep. Peter Roskam (Ill.), a deputy GOP whip, on Thursday labeled the Senate bill a “pipe dream” that won’t come up for a vote in the House.

“The House has no capacity to move that bill in its entirety,” Roskam said at a breakfast hosted by the National Review. “It just won’t happen.”

Most conservative Republicans have dismissed the Senate bill as insufficient in its attempts to protect the southern border and not tough enough on people who have broken U.S. laws.

To mark the significance of the Senate vote, Vice President Biden presided over the chamber while Senate Majority Leader Harry M. Reid (D-Nev.) made the rare request that senators sit at their assigned desks and stand to vote during the roll call.

After the last vote was cast, there was a long pause. The chamber was unusually packed. Several House lawmakers had joined staffers along the walls, and above, the public galleries were at capacity. One section was full of young people wearing blue T-shirts that read: “11 Million Dreams.”

After Biden read the final tally, some spectators clapped but were quickly quieted. The silence did not last.

“Yes we can! Yes we can!” the group in blue chanted.

“Thank you!” shouted a man wearing a graduation gown.

President Obama, traveling in Africa, hailed the results.

“Nobody got everything they wanted. Not Democrats. Not Republicans. Not me,” Obama said. “But the Senate bill is consistent with the key principles for common-sense reform that I — and many others — have repeatedly laid out.”

“Today, the Senate did its job,” he added. “It’s now up to the House to do the same.”

But House Republicans have adopted a piecemeal approach to the immigration issue, departing sharply from the comprehensive strategy carried out by the Senate.

On Thursday, the House Judiciary Committee approved a proposal for visas for high-skilled workers. Earlier, the panel backed legislation that would make it a federal crime to be in the United States illegally and a new agricultural guest-worker program that differs from the Senate proposal.

Anticipating the House-Senate divide, Sen. John McCain (R-Ariz.) said after the vote that he had a simple request of his former House colleagues: “We ask for your consideration and we stand ready to sit down and negotiate with you.”

The political consequences going into the 2014 and 2016 election years could be significant. Sen. Lindsey O. Graham (S.C.), who worked with McCain on the bill, reminded his fellow GOP colleagues that failure to agree on immigration reform could spell more trouble for the party at the polls.

“Self-deportation as a policy of the Republican Party is in our rearview mirror, thank God,” he said, recalling Republican presidential nominee Mitt Romney, who suggested last year that illegal immigrants would “self-deport” when they realized they couldn’t get jobs without proper legal documentation. Many in the GOP saw Romney’s comment as an example of the many ways in which the party had alienated Latino voters, thereby costing itself support at the polls.

Thursday’s vote would not have been possible without the “Gang of Eight,” which united McCain and Charles E. Schumer (D-N.Y.), two of the chamber’s most high-profile senators, with Durbin, Graham, Robert Menendez (D-N.J.), Michael Bennet (D-Colo.), Marco Rubio (R-Fla.) and Jeff Flake (R-Ariz.).

After releasing the group’s compromise agreement with great fanfare in April, its members helped approve significant changes over 37 hours of deliberations in the Senate Judiciary Committee that spread over three weeks. Debate did not go as smoothly when it began in the full Senate this month. Party leaders often clashed over how many amendments would be considered and whether those proposals would require a simple majority or a supermajority of 60 votes to pass.

Sen. Jeff Sessions (R-Ala.), who voted against the bill Thursday, complained that it “came about as a direct result of the fact that the forces that shaped it had goals that were important to them, but these goals are not coterminous with, they’re not in harmony with, the nation as a whole. The realpolitik gang that put it together seemed fine with that.”

The agreement would increase the number of visas available to high-skilled workers, most of whom work in the fields of science and technology, and also to lower-skilled people who take jobs in the construction and hospitality industries. Immigrant farmworkers also would be admitted under a temporary guest-worker program.

A cross section of society — dairy farmers, educators, religious leaders, labor officials and corporate titans, including Microsoft chief executive Steve Ballmer — hailed the Senate vote and called on the House to debate the immigration issue in an equally bipartisan fashion.

McCain credited the coalition of supporters, “not ever assembled before,” for helping push the Senate to act.

“What we’re going to have to do if we want to see this bill through to fruition is to have that coalition out there working actively on behalf of this legislation,” McCain said.

Aaron Blake and David A. Fahrenthold contributed to this report.