WASHINGTON (AP) — The Democratic-controlled House voted Tuesday to pass a $1.4 trillion government spending package, handing President Donald Trump a victory on his U.S.-Mexico border fence while giving Democrats spending increases across a swath of domestic programs.

The hard-fought legislation also funds a record Pentagon budget and is serving as a must-pass legislative locomotive to tow an unusually large haul of unrelated provisions into law, including an expensive repeal of Obama-era taxes on high-cost health plans, help for retired coal miners, and an increase from 18 to 21 in the nationwide legal age to buy tobacco products.

The two-bill package, some 2,371 pages long after additional tax provisions were folded in on Tuesday morning, was unveiled Monday afternoon and adopted less than 24 hours later as lawmakers prepared to wrap up reams of unfinished work against a backdrop of Wednesday's vote on impeaching Trump.

The House first passed a measure funding domestic programs on a 297-120 vote. But one-third of the Democrats defected on a 280-138 vote on the second bill, which funds the military and the Department of Homeland Security, mostly because it funds Trump's border wall project.

The spending legislation would forestall a government shutdown this weekend and give Trump steady funding for his U.S.-Mexico border fence, a move that frustrated Hispanic Democrats and party liberals. The year-end package is anchored by a $1.4 trillion spending measure that caps a difficult, monthslong battle over spending priorities.

The mammoth measure made public Monday takes a split-the-differences approach that's a product of divided power in Washington, offering lawmakers of all stripes plenty to vote for — and against. House Speaker Nancy Pelosi, D-Calif., was a driving force, along with administration pragmatists such as Treasury Secretary Steven Mnuchin, who negotiated the summertime budget deal that it implements.

The White House said Tuesday that Trump will sign the measure.

Story continues

”The president is poised to sign it and to keep the government open,” said top White House adviser Kellyanne Conway.

The bill also offers business friendly provisions on export financing, flood insurance and immigrant workers.

The roster of add-ons grew over the weekend to include the permanent repeal of a tax on high-cost “Cadillac” health insurance benefits and a hard-won provision to finance health care and pension benefits for about 100,000 retired union coal miners threatened by the insolvency of their pension fund. A tax on medical devices and health insurance plans would also be repealed permanently.

The cost of the package grew as lawmakers added the repeal of three so-called “Obamacare” taxes and extended expiring tax breaks. Those policy changes will add $428 billion to the deficit over 10 years.

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. Democrats controlling the House succeeded in winning a 3.1% raise for federal civilian employees and the first installment of funding on gun violence research after more than two decades of gun lobby opposition.

Late Monday, negotiators unveiled a scaled-back $39 billion package of additional business tax breaks, renewing tax breaks for craft brewers and distillers, among others. The so-called tax extenders are a creature of Washington, a heavily lobbied menu of arcane tax breaks that are typically tailored to narrow, often parochial interests like renewable energy, capital depreciation rules and racehorse ownership. But a bigger effort to trade refundable tax credits for the working poor for fixes to the 2017 GOP tax bill didn't pan out.

The sweeping legislation, introduced as two packages for political and tactical purposes, is part of a major final burst of legislation that's passing Congress this week despite bitter partisan divisions and Wednesday's likely impeachment of Trump. Thursday promises a vote on a major rewrite of the North American Free Trade Agreement, while the Senate is about to send the president the annual defense policy bill for the 59th year in a row.

The core of the spending bill is formed by the 12 annual agency appropriations bills passed by Congress each year. It fills in the details of a bipartisan framework from July that delivered about $100 billion in agency spending increases over the coming two years instead of automatic spending cuts that would have sharply slashed the Pentagon and domestic agencies.

The increase in the tobacco purchasing age to 21 also applies to e-cigarettes and vaping devices and gained momentum after Senate Majority Leader Mitch McConnell signed on. But anti-smoking activists said the provision didn't go far enough because it failed to ban flavored vaping products popular with teenagers.

“The evidence is clear that flavored e-cigarettes are driving the youth epidemic,” said Matthew Myers, president of the Campaign for Tobacco-Free Kids. “As long as flavored e-cigarettes remain available, kids will find ways to get them and this epidemic will continue.”

Other add-ons include a variety of provisions sought by business and labor interests and their lobbyists in Washington.

For business, there's a seven-year extension of the charter of the Export-Import Bank, which helps finance transactions benefiting U.S. exporters, as well as a renewal of the government's terrorism risk insurance program. The financially troubled government flood insurance program would be extended through September, as would several visa programs for both skilled and seasonal workers.

Labor won repeal of the so-called Cadillac tax, a 40% tax on high-cost employer health plans, which was originally intended to curb rapidly growing health care spending. But it disproportionately affected high-end plans won under union contracts, and Democratic labor allies had previously succeeded in temporary repeals.

Democrats controlling the House won increased funding for early childhood education and a variety of other domestic programs. They also won higher Medicaid funding for the cash-poor government of Puerto Rico, which is struggling to recover from hurricane devastation and a resulting economic downturn.

While Republicans touted defense hikes and Democrats reeled off numerous increases for domestic programs, most of the provisions of the spending bill enjoy bipartisan support, including increases for medical research, combating the opioid epidemic, Head Start, and child care grants to states.

Democrats also secured $425 million for states to upgrade their election systems, and they boosted the U.S. Census budget $1.4 billion above Trump's request. They won smaller increases for the Environmental Protection Agency, renewable energy programs and affordable housing.

“I am so proud that we are able to do so much good for children and families across the country and around the world,” said House Appropriations Committee Chairwoman Nita Lowey, D-N.Y.

The outcome in the latest chapter in the long-standing battle over Trump's border wall awards Trump with $1.4 billion for new barriers — equal to last year's appropriation — while preserving Trump's ability to use his budget powers to tap other accounts for several times that amount. That's a blow for liberal opponents of the wall but an acceptable trade-off for pragmatic-minded Democrats who wanted to gain $27 billion in increases for domestic programs and avert the threat of simply funding the government on autopilot.

"Many members of the CHC will vote against it," said Congressional Hispanic Caucus Chairman Joaquin Castro, D-Texas. “It's true that there are a lot of good things and Democratic victories in the spending agreement. I think everybody appreciates those. What members of the Hispanic Caucus are concerned with is the wall money, the high level of detention beds, and most of all with the ability of the president to transfer money both to wall and to detention beds in the future.”

The bill also extends a long-standing freeze on lawmakers' pay despite behind-the-scenes efforts this spring to revive a cost-of-living hike approved years ago but shelved during the Obama administration.

Because dozens of Democrats oppose the border wall, Pelosi paired money for the Department of Homeland Security with the almost $700 billion Pentagon budget, which won more than enough GOP votes to offset Democratic defections.