The Senate on Thursday passed two spending bills it plans to approve to prevent a government shutdown.

The first measure covers eight appropriations bills, and passed by a 71-23 margin. The second piece includes the other four. The House has already cleared both pieces of legislation.

The president needs to sign the bills by Friday to keep federal departments running. Trump's advisors have said he will approve the measures to fund the government through Sept. 30.

The $1.4 trillion appropriations package boosts spending for both the military and domestic programs. It also scraps key taxes to fund the Affordable Care Act and raises the U.S. tobacco buying age to 21.

Congress appears poised to avoid another shutdown after lawmakers avoided a major dispute with the president over funding for barriers at the U.S.-Mexico border. The package includes nearly $1.4 billion for border fencing — the same level as last year — which caused a group of House Democrats to oppose it.

Some Republicans also voted against the funding legislation, criticizing the increase in spending and a rushed approval process.

Earlier this year, Congress approved a two-year deal to suspend the federal debt ceiling and set budget levels. It took months, and two short-term spending bills, for lawmakers to agree on where to actually send the money.

Democrats have pointed to what they call several priorities included in the sprawling spending package. It puts $25 million toward federal gun violence research, funding the effort for the first time in 20 years. The legislation also sets aside $425 million for election security grants.

Trump and Republican allies have cheered the $22 billion increase in defense spending and 3.1% raise for military service members included in the spending plans.

The bills, which would repeal a variety of health care-related levies including the "Cadillac" tax on high-cost plans, could add $500 billion to federal debt over a decade, according to the Committee for a Responsible Federal Budget.

This story is developing. Please check back for updates.

Subscribe to CNBC on YouTube.