WASHINGTON — Senate Democrats on Tuesday blocked a Republican bill that would finance the Department of Homeland Security, objecting to a measure that would have gutted President Obama’s recent executive actions on immigration. The vote set up an urgent confrontation over the department, which will see its funding run out at the end of the month.

The bill, passed by the House recently, would have revoked the president’s action that provides legal protection for as many as five million undocumented immigrants, including children. Democrats said that was unacceptable, and Mr. Obama has promised to veto any legislation that reversed his directives on immigration.

The showdown over the $40 billion measure is most likely the first of many, as Democrats turned to procedural moves to stop votes much as Republicans did when they were in the minority. On Tuesday, Republicans blamed Democrats for the vote, which was 51 to 48, to block the bill from coming to the Senate floor.

“If they’re going to dig their heels in and say, ‘We’re going to refuse to fund the Department of Homeland Security,’ I think they’re going to be held accountable for that,” said Senator John Cornyn of Texas, the No. 2 Senate Republican.