WASHINGTON — The political divide over immigration grew even wider Wednesday as the Republican-led House of Representatives passed legislation that would undo President Obama’s executive action shielding from deportation nearly 5 million immigrants here illegally.

The amendment, part of a larger bill that provides nearly $40 billion to finance the Department of Homeland Security, also would reverse Obama’s 2012 order deferring deportation of young immigrants brought to the country as children and would roll back policies that reduce the likelihood that immigrants without criminals records would be deported.

The 236-191 vote on funding the agency stirred up the turmoil between the White House and House Republicans who saw Obama’s November executive order as an unconstitutional power grab.

“House Republicans came to a consensus that the president cannot be trusted to do anything except enforce the laws that he likes and refuse to enforce laws that he doesn’t and make up laws on his own,” said Rep. Steve King, R-Iowa, one of the most outspoken critics of Obama’s immigration policy.

Hours after the vote, the White House slammed the measure, describing it as “political theater,” and said Obama would veto the proposal if it arrived on his desk as it was passed. Press Secretary Josh Earnest called the vote “bad policy” and “bad politics.” It’s not the right time to be complicating funding for the Homeland Security agency considering last week’s terrorism attack in Paris, he said.

“There’s never a good time to muck around with the funding of the Department of Homeland Security, but given the events of the last week, this seems like a particularly bad time to do so,” Earnest said.

House Speaker John Boehner, R-Ohio, called Obama’s executive action “an affront to the rule of law.” He said the president left Republicans no choice but to try and stop the unilateral actions, which Obama himself had said in the past that he did not have the authority to do.

“What we are dealing with is a president who has ignored the people, has ignored the Constitution and even his own past statements,” Boehner said.

Thomas Mann, a senior fellow at the left-leaning Brookings Institution, a Washington think tank, said the House vote was largely an effort by leadership to appease the more conservative wing of the party.

“I think the House leadership figures the Senate will save them,” Mann said. “They’ll write a different bill and send it back. At that point, Boehner can argue ‘Well, we tried our way but we don’t have it, so let’s get this done and move on.’ ”

While conservative Republicans praised the effort to quash Obama’s immigration policy, more than two dozen House Republicans voted against an amendment that would have exposed hundreds of thousands of immigrants brought to the country as children to deportation. Seven Republicans, including Rep. Renee Ellmers, R-N.C., and Rep. Mario Diaz-Balart, R-Fla., also voted against an amendment blocking the executive order.

“I don’t think, as drafted, this has any shot of stopping the executive order,” Diaz-Balart said. “If anything, I think it actually strengthens the president’s hand.”

Diaz-Balart, who was critical of the executive order, said the only way to stop the executive order was to pass legislation that supersedes it.