(CNN) The House of Representatives passed legislation funding most federal agencies through March 23, and the Pentagon for a full fiscal year, roughly two days before the government faces a shutdown.

The bill passed 245-182, but this is just the first step. The bill will next go the Senate, where Democrats are expected to oppose it because it doesn't also provide longer term money for domestic programs like opioid recovery efforts, transportation, and education.

Senate leaders are expected to strip out the military portion and attempt to pass a broader budget deal that Republicans and Democrats have been negotiating for months. But any changes to the measure mean the House will need to approve legislation before midnight on Thursday to avoid any government shutdown.

Republicans muscled their spending bill through above Democratic objections. GOP leaders tacked on a full year of defense funding to sweeten the deal for conservative and defense hawks in their ranks who have been emphatic that they wouldn't support the fifth continuing resolution in six months without some kind of certainty for the country's military.

The mood on Capitol Hill was still optimistic, however, Tuesday afternoon as Democratic and GOP leaders postured they are closer than ever to reaching a budget caps deal that would set the targets for a much larger, and longer term spending bill.

Read More