WASHINGTON — A divided House voted Friday to ease visa restrictions for a limited pool of foreign workers — those with advanced science and math degrees from U.S. universities — previewing a fight over how far Congress should go in changing the country’s immigration laws.

Leaders of both parties think immigration will be one of the biggest challenges they will face after the new Congress convenes in January, pitting lawmakers who want a sweeping immigration overhaul against those who think an incremental approach stands the best chance of passing both houses.

The STEM Jobs Act the House approved by a vote of 245 to 139 — with just 27 Democrats supporting it — stands little chance of advancing in the Senate, where Democrats have control. STEM stands for science, technology, engineering and mathematics.

The Obama administration opposes the bill, calling it too “narrowly tailored” and incompatible with President Obama’s vision for a more comprehensive approach.

The House bill, which would provide for 55,000 visas for foreign graduates of U.S. universities who have doctoral and master’s degrees in science, technology, engineering or mathematics, was an attempt to reconcile concerns within the Republican Party. And some Republicans acknowledged its shortcomings.

“It is not the panacea,” said Rep. Mario Diaz-Balart, who represents a stretch of South Florida west of Miami. “It does not solve all the problems. But it takes a huge step.”

Businesses, particularly technology and software companies, had pushed for the legislation as a way to help address the shortage of skilled U.S. workers.

But some Democrats said Friday that the bill set immigrant groups against one another by deepening demographic divides.

“That is not America,” said Rep. Luis Gutierrez of Chicago. “There was no special line for Ph.D.s and master’s-degree holders at Ellis Island.”

Rep. John Conyers Jr. of Michigan called the bill “a naked attempt to satisfy anti-immigrant groups.”

GOP leaders also added a provision to the bill making it easier for immigrants working in the country legally to bring their spouses and children to the United States while they wait for their visa applications to be approved. Typically, relatives wait more than two years to be reunited. About 80,000 such family-based visas are issued every year.

Looming over the House vote was a political reality: Republicans received just a sliver of the Hispanic vote in the elections last month, and the party is divided over how best to improve its standing with such a large and growing demographic.

Some Republicans are eager to move forward with legislation that would tighten border controls but also start opening a path to citizenship for some of the estimated 11 million illegal immigrants now in the United States, a move that could help reverse impressions among Hispanics that the party is hostile to immigrants. But many Republicans are also wary of the furor that could arise among conservative voters over any perceived softness on those who are in the U.S. illegally.

Some leading Republicans have become more vocal about their desire to see immigration legislation pass. Rep. Eric Cantor of Virginia, the House majority leader, published an op-ed article in multiple newspapers this week making an economic argument to pass the House bill.

“Entrepreneurship and job creation won’t kick into high gear until businesses have the workers they need to drive growth and innovation,” he wrote, “and immigrants have always been a key part of the equation.”

In the Senate, there are several different immigration proposals but no clear road to passage. One plan favored by Sen. Marco Rubio, R-Fla., would start by providing a path to citizenship for children who were brought to the U.S. illegally by their parents.

More comprehensive efforts have languished in the Senate since 2010.

Recently, new talks have begun about a bill that would include the House plan as part of a package that would combine enhanced border security with ways for illegal immigrants to become citizens.