A U.S. Customs and Border Patrol officer stands on a bridge at a port of entry between Mexico and United States in McAllen, Tex., on May 10, 2017. (Carlos Barria/Reuters)

The House voted 282 to 137 Wednesday in favor of a bill that would allow U.S. Customs and Border Protection to waive a mandatory lie-detector test for applicants from law enforcement or the military, raising alarms that the move will weaken standards at the agency.

Supporters argued that the bill would relieve chronic staffing shortages at CBP, which guards the nation’s ports and borders, and it follows calls from President Trump to beef up border security. But immigrant advocates expressed fear that the measure will lead to corruption and abuse.

Rep. Michael McCaul (R-Tex.), chairman of the House Homeland Security Committee, said on the House floor that the agency is “stretched thin,” with 1,800 vacancies in the Border Patrol and 1,000 in customs, and needs to hire more quickly.

“We must make sure we have an adequate force to protect our borders,” McCaul said. “This should not be a partisan issue.”

The bill would allow the CBP commissioner to waive a polygraph in the case of a full-time state or local law enforcement officer who has passed the test during the prior 10 years, among other requirements. Federal law enforcement and military members or veterans may also skip the test if they have undergone certain background checks or security clearances.

Critics worried that waiving polygraph tests — even for experienced military and law enforcement officers — risks having problem candidates slip through. CBP is still recovering from allegations of corruption and excessive use of force that led Congress to require polygraphs at the agency in 2010.

According to the Government Accountability Office, CBP reported that hundreds of employees were arrested for misconduct from fiscal 2005 to 2012, although the agency said it was a tiny share of its overall workforce.But more than 140 current or former workers were arrested on corruption charges, including immigrant and drug smuggling, and 125 were convicted as of 2012.

Others fear that the bill aims to subvert the agency’s high polygraph failure rate. More than 60 percent of CBP’s applicants fail the test, according to CBP.

Acting CBP commissioner Kevin K. McAleenan has vowed to maintain hiring standards and said the agency will continue to use the polygraph for other applicants.

Some Democrats were divided over the bill Wednesday, including in the Congressional Hispanic Caucus, which has been an outspoken critic of Trump’s immigration policies.

Reps. Filemon Vela, Henry Cuellar and Vicente Gonzalez, all Democrats from border regions in Texas, spoke in favor of the bill.

Vela said it is unfair to taint all of CBP because of “a few rogue agents” — just as, he said, it was unfair of Trump to suggest that all Mexican immigrants are criminals.

“This bill simply grants CBP limited authority to waive a single step,” Vela said.

But Rep. Luis V. Gutiérrez (D-Ill.) said his colleagues were aiding Trump’s “fantasy of a mass deportation force.”

“You cannot spin it any other way,” he said.

Rep. Michelle Lujan Grisham (D-N.M.), caucus chairwoman, proposed an amendment that would have delayed implementing the bill until CBP completed a pilot program using an alternative polygraph test and the Homeland Security Inspector General determined that the bill would not endanger national security. Her amendment failed.

“We shouldn’t blindly experiment with our nation’s security,” she said.

A similar bill is pending in the Senate and is generating debate. Sen. Kamala D. Harris (D-Calif.) has urged colleagues to take a measured approach.

“Now is not the time to in any way to loosen hiring standards,” she said.