It came as little surprise when Republicans on Capitol Hill decided this month that the first bill they would push through Congress in the Trump era would be one to make it easier to deport immigrants accused of minor crimes.
After all, President-elect Donald J. Trump won election in November, sweeping Republicans to unified control of Congress, after a campaign promising a severe immigration crackdown.
What was less expected was what came next: Dozens of Democrats in the House and a smaller but critical bloc in the Senate joined the G.O.P. in pushing the legislation to the brink of enactment, culminating in a test vote on Friday that cleared the final hurdle to its passage.
It was an outcome that exposed major divisions among Democrats about how to position themselves on immigration, and foreshadowed the immense challenge of maintaining unity on a pressing topic that Mr. Trump has made his signature issue. After years of opposing Mr. Trump’s immigration agenda at every turn, some Democrats — particularly those who are looking toward potentially tough re-election campaigns — appear to have concluded that “hell no” is not a winning strategy, at least not in every case.
The dynamic was on display last week in the House, when 48 Democrats joined Republicans in supporting the Laken Riley Act, which would mandate the detention and potential deportation of undocumented migrants charged with burglary, theft, larceny or shoplifting. Representative Ritchie Torres, a New York Democrat whose Bronx district swung 22 points toward Mr. Trump, backed the bill after having opposed it 10 months ago.
“You have to meet people where they are, even if your ideological priors might lead you in a different direction,” Mr. Torres, who is exploring a run for governor, said in an interview. “I do worry that when we vote against bills like the Laken Riley Act, we run the risk of seeming out of touch with most Americans on the issue of immigration and border security.”