The House passed a bipartisan bill Wednesday night that could give legal status and a path to citizenship to hundreds of thousands of unauthorized immigrants working in agriculture.

The legislation, the product of months of discussions, represents a rare moment of bipartisan agreement on one of the most contentious topics of the Trump administration, ultimately passing by a vote of 260-165 and attracting 23 Republicans.

The bill could legalize up to about 325,000 immigrants currently working in agriculture who do not have legal status. It’s still only a fraction of the 12 million unauthorized immigrants estimated to be living in the US and the more than 2 million that would be legalized under the “Dream and Promise Act” that passed the House in June. But it’s the biggest legalization effort supported by Republicans in recent memory.

Republicans are usually reluctant to back any kind of legalization of unauthorized immigrants — immigration restrictionist groups have lambasted the bill as a means of securing “cheap foreign labor” at the expense of American workers — but the lawmakers represent districts where agriculture is a major industry.

The Senate still has to agree to vote on the bill. But its success in the House signals that a piecemeal approach to immigration reform could be more feasible than a comprehensive bill like the “Gang of Eight” proposal that failed in 2013. A similarly narrow bipartisan bill that would have eliminated per-country caps on employment-based green cards passed the House in July with significant bipartisan support before it was ultimately blocked in the Senate in September.

“I am thankful that the House advanced this effort to protect our existing farmworkers and promote an enduring workforce for agriculture. I look forward to working with our colleagues in the Senate to get this bill passed into law.” Rep. Jimmy Panetta (D-CA), who helped lead the negotiations, said in a statement Wednesday.

The US agricultural industry has relied on immigrant labor for decades, dating back to the Bracero Program in the 1940s that allowed millions of Mexicans to come to the US as farmworkers. Another large influx of unauthorized workers came during the 1990s before a slowdown that started around 2008, leaving agricultural employers unable to replace an aging workforce.

Congress has been wrestling with how to respond to labor shortages in agriculture and reduce the industry’s reliance on unauthorized workers ever since. Under President Donald Trump, that mission has taken on new urgency after his administration’s immigration raids targeting the agricultural sector.

At one raid in August, 680 workers were arrested at two Mississippi poultry plants. It’s not clear whether the plants have been able to replace those workers, but they said in a statement in August that they were recruiting at a job fair and encouraging applicants to have two forms of identification documents.

The bill would give unauthorized farmworkers a path to citizenship

The bill would give farmworkers who have worked in agriculture for at least 180 days over the past two years the ability to apply for “Certified Agricultural Worker” status, which can be renewed in six-month or five-year increments if they continue to work in agriculture for at least 100 days a year. It also offers long-term farmworkers a path to a green card, which requires at least four more years of experience in the industry and a $1,000 fine.

The bill streamlines the application process for the H-2A temporary visa program for seasonal agricultural workers, which admitted over 196,000 people in 2018. It allows for up to 40,000 green cards to be granted annually, either through the sponsorship of an employer or if workers maintain H-2A status for 10 years.

It also creates a new program capped at 20,000 visas for year-round agricultural industries, which were previously barred from participating in the H-2A program and were consequently facing labor shortages, including dairy farming and producers of other animal products.

The bill tightens up enforcement, requiring that farm employers participate in the federal E-Verify program, with no exemptions for small farmers. And it would freeze the minimum wage set by the government for one year and cap increases at 3.25 percent for the next nine years — which might draw opposition from labor groups.

David Bier, a policy analyst at the libertarian Cato Institute who met with members on the Hill amid the negotiations, said that the parties “started pretty far apart” but were able to reach a compromise in which Republicans recognized that legalizing farmworkers who have been working in the shadow economy for years is “absolutely essential to fixing the system.”

“Without legalization for the undocumented farmworkers, you’re still going to have the problem of having a black market,” he said. “That’s going to result in continued immigration raids and uncertainty for employers. From the Republicans’ perspective, the only way to get back to certainty and legality is to clean the slate, start fresh, and move forward with a legal workforce.”

It’s unclear whether Senate Republicans might proffer an alternative to the compromise bill passed in the House Wednesday or whether it might be haunted by a previous failed proposal brought by Rep. Bob Goodlatte (R-VA). He had introduced a version of temporary agricultural worker visa reform back in 2018 but most Democrats viewed that bill as a nonstarter.

A significant bipartisan majority backed the bill in the House, which might push Senate Majority Leader Mitch McConnell to bring the bill to the floor for a vote. But even then, it will still need Trump’s backing, unless lawmakers can secure a veto-proof majority.

“Right now, there isn’t an alternative. They’ll either vote with the farmers or against them,” Bier said.