Senator Charles E. Schumer, Democrat of New York and an author of the measure, said that not including the provision amounted to “rank discrimination.” But he ultimately concluded, “As much as it pains me, I cannot support this amendment if it will bring down the bill.”

Similarly, Senator Al Franken, Democrat of Minnesota, said: “This is the definition of a Hobson’s choice. In my bones, I believe in equality.”

But Mr. Graham reflected the view of his Republican colleagues when he said: “You’ve got me on immigration. You don’t have me on marriage. If you want to keep me on immigration, let’s stay on immigration.”

Ultimately, Mr. Leahy withheld his amendment “with a heavy heart,” though he can still bring it up on the Senate floor.

Mr. Hatch’s amendment, which reflects the compromise he reached after lengthy negotiations led by Mr. Schumer, raises the minimum number of visas annually for high-skilled foreign workers — known as H-1B visas — to 115,000, from 110,000 in the bill, while keeping the maximum at 180,000 a year. More important, aides to Mr. Hatch said, his provision includes a mechanism based on conditions in the labor market, intended to ensure that companies based in the United States can bring in qualified foreign workers when jobs are not filled by Americans, but decreases visas when they are.

His provision would also make it easier for employers to hire foreign workers, because it lightens the burden on them to demonstrate that they first tried to hire a qualified American worker.

Mr. Hatch’s amendment clarifies distinctions between companies in which the majority of engineers and computer technicians are Americans, and companies with mostly foreign workers. Under the measure, more stringent restrictions would apply to the companies with a foreign labor force, like many Indian outsourcing companies, raising incentives to hire more Americans.