J. Scott Applewhite, Associated Press
Rep. Walter B. Jones, R-N.C., holds up a copy of the Constitution while talking to reporters as House Republicans emerge from a closed-door meeting on how to deal with the impasse over the Homeland Security budget, at the Capitol in Washington, Thursday, Feb. 26, 2015.

WASHINGTON — Congressional Republicans aimed Friday to approve a short-term spending bill for the Department of Homeland Security that would avert a partial agency shutdown hours before it was to begin.

The legislation leaves intact Obama administration executive actions on immigration that Republicans have vowed to overturn. But Republican leaders insisted that passing a short-term bill preserved their ability to keep fighting them.

An early vote in the House clearing the way for final passage of the bill was approved 240-183. But in the hours after, the outcome began to look uncertain as Republican leaders sent the House into recess as they sought to round up the votes they needed to pass the bill.

Democrats announced their opposition to the three-week measure, forcing House Speaker John Boehner to rely solely on GOP votes. And conservative lawmakers who have thwarted Boehner's plans on a variety of issues were balking because the legislation doesn't undo President Barack Obama's executive actions granting work permits to millions of immigrants in the United States illegally.

"I am not going to vote under any circumstances to fund illegal conduct," said Rep. Mo Brooks, R-Ala. "It does not make any difference whether the funding is for three weeks, three months or a full fiscal year. If it's illegal, it's illegal."

GOP leaders urgently pleaded for the measure. Without action, DHS would begin to shut down at midnight Friday, furloughing 30,000 workers. Another 200,000 would be deemed essential and continue to report to work, albeit without pay.

"The House must pass this bill in short order to keep the lights on at the Department of Homeland Security in the near term," said Rep. Harold Rogers, R-Ky. "Hopefully, this will buy us this additional time that we clearly need."

As debate proceeded in the House, the Senate voted 68-31 to approve a full-year bill free of contentious immigration provisions. Some House Republicans predicted that they would eventually end up doing the same thing.

For now, the three-week stopgap measure, if approved, would allow lawmakers to keep the Homeland Security Department running at a time of heightened threats worldwide — even if it does little more than postpone the fight for another day. The bill would extend current funding levels for the department until March 19.

If the House does approve the three-week measure, it was expected to quickly pass the Senate and gain Obama's signature.

Leadership-aligned lawmakers sought to win over conservatives arguing that a federal judge has already put Obama's policies on hold. That argument was unpersuasive to some.

At the same time some of the more establishment-minded lawmakers said the House should not be wasting its time with a stopgap bill but should accept the inevitable and vote to fund the department through the rest of the year with no strings attached. Since Senate Democrats have refused to agree to a spending bill rolling back Obama's immigration policies, and Obama has threatened to veto any such legislation, these lawmakers argued the House would have to retreat in the end anyway.

"The only question is when — tomorrow or in three weeks," said Rep. Charlie Dent, R-Pa. "Some folks just have a harder time facing political reality than others."

Homeland Security Secretary Jeh Johnson, who has been on Capitol Hill every day lobbying lawmakers to fund his department, sent a plea to congressional leaders Thursday asking them to pass a full-year bill, not a stop-gap measure. "A short-term continuing resolution exacerbates the uncertainty for my workforce and puts us back in the same position, on the brink of a shutdown just days from now," Johnson wrote.

Associated Press writers Charles Babington, Andrew Taylor, Matthew Daly and Laurie Kellman contributed to this report.