UPDATE: On Friday after threatening to veto the bill, which would have caused a government shutdown, President Trump signed the bill. "There are a lot of things that I'm unhappy about in this bill," he said. "I say to Congress, I will never sign another bill like this again. I'm not going to do it again."

Congress cleared a spending bill Friday for the 2018 fiscal year that allocates $1.3 trillion. Despite the Trump administration’s requests for drastic cuts, lawmakers set aside increased funds for clean energy programs. Trump tweeted Friday that he may veto the bill.

In the final text, the Department of Energy actually received a $3.77 billion boost in funding, bringing the agency’s budget to a total of $34.5 billion. The Office of Energy Efficiency and Renewable Energy (EERE) received $2.32 billion, the Advanced Research Projects Agency-Energy (ARPA-E) received $353 million, and the Office of Science — which houses national labs like Lawrence Berkeley — received $6.3 billion. All those budgets were increased from 2017.

The whopping 2,232-page deal adds specifics to a broad-strokes budget deal passed last month, after a brief government shutdown. It also included late additions and riders, making it a controversial sell for some legislators who said they didn’t have time to digest its contents.

But clean energy advocates felt they came out on top.

“It’s been a long time coming, but Congress got it right with this bill,” said Ben Evans, vice president of government affairs and communications at the The Alliance to Save Energy, in a statement.

Other renewables and environmental advocates applauded the legislation as a rebuke of the Trump agenda.

“This spending bill is a repudiation of President Trump’s extreme budget cuts,” said League of Conservation Voters President Gene Karpinski in a statement. “It recognizes that we need more investments — not fewer — to protect public health, boost our outdoor recreation economy, and grow clean energy jobs.”

In applauding the deal, groups also hinted at a sore spot for the administration: competition from abroad.

“It’s clear that Congress recognizes the incredible value EERE, ARPA-E and the National Renewable Energy Laboratory (NREL) bring to the research, development and deployment of many important electric power innovations,” said Gregory Wetstone, president and CEO at the American Council on Renewable Energy, in a statement. “Without support for these critical energy R&D programs, the U.S. is at risk of falling behind other countries that are investing heavily in a rapidly growing global renewable energy industry.”

Citizens for Responsible Energy Solutions Managing Director Heather Reams said in a statement that the bill will “allow the U.S. to maintain its global leadership and competitive edge.”

Lawmakers apparently agreed. Many of the programs affected, such as ARPA-E, historically have received bipartisan support.

In addition to traditional energy innovation programs, the final appropriations bill also sets aside about $2 billion a year through 2027 for wildfire disaster funds and asks utilities to coordinate with government on vegetation management. The Office of Electricity Delivery and Reliability, which focuses on resilience in infrastructure, got $248 million. The Office of Nuclear Energy got $1.2 billion. The Innovative Technology Loan Guarantee program, which provides money for innovative clean energy projects, got $33 million. And the Advanced Technology Vehicles Manufacturing Loan Program got $5 million.

Despite the positive news contained in this year’s appropriations, the clean energy industry is still staring down cuts in Trump’s 2019 budget proposal. Earlier this week Secretary Rick Perry defended the cuts in front of the Senate Energy and Natural Resources Committee.

“Just because there’s a reduction in the line item doesn’t necessarily mean there will be a reduction in results,” he told legislators.

Though drastic, the cuts for next year are unlikely to pass Congress. But advocates are bracing for a fight.

“Looking ahead, as Congress begins to set appropriations for the upcoming fiscal year, we will encourage them to once again reject proposed cuts and increase funding to energy efficiency programs so we can build on their success,” said The Alliance to Save Energy's Evans.