THE MOST far-reaching overhaul of the nation’s immigration system in a generation has emerged mostly unscathed from the Senate Judiciary Committee. The bill’s bipartisan sponsors showed that, even in Washington, the center can sometimes hold. Though the legislation, all 800-odd pages of it, contains provisions that pained Democrat and Republican backers alike, they gritted their teeth and voted it out of committee and onto the Senate floor.

The bill’s prospects remain cloudy, particularly in the Republican-dominated House. Still, it remains the best hope for legalization and eventual citizenship for 11 million undocumented immigrants since the last major attempt at immigration reform failed in 2007.

The Senate committee’s handling of more than 200 amendments — many of them designed to gut, cripple or poison the original legislation — was a model of big-picture problem-solving trumping ideology and partisan grandstanding. The committee’s Democrats and some of its Republicans united to squash restrictionist attempts to strip the bill of a path to citizenship for illegal immigrants; to tie progress on legalization to unachievable attempts to make the nation’s borders airtight; and to slash future legal immigration levels, notwithstanding the labor market’s demand.

The bill’s bipartisan backers were just as resolute in opposing amendments that would have been unpalatable to many Republicans. Chief among these was a proposal by Sen. Patrick J. Leahy (D-Vt.), the committee chairman, to allow gay Americans to sponsor their foreign-born spouses for green cards.

That provision would have made the bill fairer and more humane; it would also have cost the support of key Republican senators, including Sen. Marco Rubio of Florida, one of the bill’s authors. Democrats who are strong advocates of gay rights, including Sens. Charles E. Schumer (N.Y.), Dianne Feinstein (Calif.) and Richard J. Durbin (Ill.), swallowed hard and urged Mr. Leahy to drop his amendment. He did.

The bill retains plenty of flaws, some of them major. Tens of thousands of migrants who have entered the country since 2011 would remain in the shadows, ineligible for legal status, owing to an unrealistic cutoff date. An artificially low limit on visas for low-skilled workers, especially in the construction industry, could create an incentive for ongoing illegal immigration. Billions of dollars for beefed-up border security programs — on a southwestern border that is already more secure than it has been in decades — is wasteful overkill.

Still, the legislation would reshape the nation’s broken-down, irrational immigration system in ways that would bear fruit for decades. After years of denial, it would recognize the nation’s competitive need for foreign workers in high-tech, agriculture and low-skilled occupations while retaining preferences for family reunification. And by offering 11 million illegal immigrants a shot at the American dream, it would remove a poisonous issue from the nation’s political debate while giving the economy a boost.

So far, a critical mass of senators in both parties seems mindful of those priorities, and the bill moves toward the full Senate with considerable momentum. Here’s hoping that the House takes those cues from the upper chamber.