The Senate on Tuesday failed to get the votes necessary to move forward on a bill intended to fund the Department of Homeland Security but also loaded with actions to undo President Barack Obama’s executive actions on immigration.

The Republicans who control the Senate could not secure enough support to overcome a Democratic filibuster of a vote on the $40bn funding bill. The GOP was working on Tuesday to determine its next move. They are under increasing scrutiny, as lawmakers must establish a plan for DHS funding before the end of the month, or the agency’s non-essential operations will shut down.

Obama said he would veto the funding bill if it included amendments to undo his executive actions, which could give about 3.7 million undocumented migrants currently in the US protection from deportation, according to the Migration Policy Institute.

Republicans needed 60 votes in favor of cloture in order to overcome the filibuster, but only had 51. Senate Democrats voted unanimously against.

Two Republicans also voted against cloture: Dean Heller, of Nevada, and the Senate majority leader, Mitch McConnell, of Kentucky – who cast a vote against his party because only senators voting on the winning side of a vote can ask for a revote.

Three former Homeland Security secretaries – Janet Napolitano, who served under Obama, and Tom Ridge and Michael Chertoff who both served under George W Bush – sent senators a letter last week asking them to pass a “clean” budget bill without the provisions aimed at Obama’s actions.

Republicans are also pursuing other routes to block the executive action. Last week, the House speaker, John Boehner, told Republicans in a closed-door meeting that he is “finalizing” options to sue the president over the executive action.