WASHINGTON — The House has cleared the way for passage of a short-term bill to fund the Department of Homeland Security and avert a partial agency shutdown.

The vote was 240-183, and it came just hours ahead of a midnight deadline to fund the agency.

The procedural vote cleared the way for final passage of the legislation later in the day in the House and Senate.

The three-week funding bill leaves intact President Barack Obama’s executive actions on immigration — even though Republicans have vowed to repeal them.

House GOP leaders insist that agreeing to a short-term bill gives them another chance to try to overturn Obama’s directives limiting deportations for millions.

But Senate Republicans have already admitted defeat and were moving to approve a full-year bill free of contentious immigration provisions.