WASHINGTON (Reuters) - The U.S. House of Representatives passed a massive spending bill on Wednesday, averting the threat of a government shutdown when the fiscal year ends at midnight on Sept. 30 as President Donald Trump indicated that he would sign it.

FILE PHOTO: Speaker of the House Paul Ryan (R-WI) speaks at a media briefing after the House Republican conference on Capitol Hill in Washington, U.S., April 17, 2018. REUTERS/Joshua Roberts

“We’re going to keep the government open,” Trump told reporters in New York when asked if he would sign the measure.

The House of Representatives passed the legislation by a strong 361 to 61 margin on Wednesday. The measure will be sent to the White House for Trump to sign or veto.

The massive package includes some $675 billion to fund the Department of Defense for the full year ending on Sept. 30, 2019, as well as about $180 billion for the Labor, Health and Human Services and Education Departments.

It also includes a measure to keep the federal government open until at least Dec. 7, even though Congress has not yet passed full-year appropriations bills covering every department.

Trump had threatened to let the government shut down on Oct. 1 if he did not get money he wanted to build a wall along the U.S.-Mexico border.

But he has backed away from that threat at least until after the Nov. 6 elections when his fellow Republicans’ control of the Senate and House are up for grabs.

The bill passed on Wednesday fulfills Trump’s desire for increased spending on the military, something strongly backed by most of his fellow Republicans. Its passage marked the first time in years that Congress has passed a defense appropriations bill.

“This is a big deal. For the first time in a decade, Congress has managed to fund our military in full and on time. It is difficult to overstate how important this is for our troops, their families and the security of the country,” Representative Mac Thornberry, the top Republican on the House Armed Services Committee, said in a statement.

The Senate passed the spending package earlier this month.