The Senate on Thursday passed a $1.4 trillion spending package, avoiding a shutdown and funding the government through the rest of the fiscal year.

The first bill in the two-bill package, covering domestic programs, passed 71 to 23. The second spending bill passed 81 to 11, and the pair will now head to President Trump's desk Friday night -- the deadline to fund the government for the rest of fiscal year 2020, or through Sept. 30. The White House said Tuesday that the president will sign the bill.

The legislation gives Trump a victory on his U.S.-Mexico border fence and gives Democrats domestic spending increases and an expensive repeal of Obama-era taxes on high-cost health plans. It provides health care and pension benefits for retired coal miners and increases the nationwide legal age to buy tobacco products, including e-cigarettes, from 18 to 21.

The tobacco measure was pushed by Sen. Majority Leader Mitch McConnell, R.-Ky.

HOUSE APPROVES $1.4 TRILLION SPENDING BILL, REPEALING OBAMACARE TAXES 

The deficit tab for the package grew, as well, with the addition of $428 billion in tax cuts over 10 years to repeal the three so-called ObamaCare taxes.

The split-their-differences legislation was carrying a large number of unrelated provisions into law, drawing protests from fiscal conservatives. It would put in place an earlier spending deal that reversed unpopular and unworkable automatic spending cuts to defense and domestic programs -- at a $2.2 trillion cost over the coming decade.

“These spending bills are a fiscal dumpster fire,” said Sen. Mike Lee, R-Utah. “This is embarrassing.”

The legislation is laced with provisions reflecting divided power in Washington. Republicans maintained the status quo on several abortion-related battles and on funding for Trump's border wall.

CONGRESS RAISES NATIONAL TOBACCO AGE TO 21 AS PART OF SPENDING PACKAGE 

Democrats controlling the House succeeded in winning a 3.1 percent raise for federal civilian employees and the first installment of funding on gun violence research after more than two decades of gun lobby opposition.

The bill provides $25 million for gun violence research, divided between the National Institutes of Health and the Centers for Disease Control and Prevention.

The bill exceeds Trump’s budget requests in every domestic category, except for his $8 billion-plus for the U.S.-Mexico wall, which was cut back to $1.4 billion -- the same as last year’s appropriation. However, Trump may use his budget powers to tap other accounts for several times that amount. Though it may anger liberal opponents to the wall, it was a trade-off for Democrats who wanted to gain $27 billion in increases for domestic programs.

Popular programs such as health research, veterans' medical care, NASA, sewer and water projects, and law enforcement grants to state and local governments would also get increases under the package. The Pentagon would receive $738 billion, a record amount, to buy expensive weapons systems such as the F-35 fighter.

CLICK HERE TO GET THE FOX NEWS APP

Democrats won $425 million for states to upgrade their election systems, and in turn, they boosted the U.S. Census budget $1.4 billion above Trump’s request.

Fox News' Chad Pergram and Alex Pappas contributed to this report, as well as The Associated Press.