The Tomago Aluminium smelter in the NSW Hunter region faced closure in 2028 due to forecasts of higher energy prices.
While the government has refused to say what the revenue return for taxpayers would be, union officials described the deal as a "win for the working class" that is expected to save thousands of jobs.
The smelter is the single largest electricity user in the nation and consumes about 10 per cent of power supplies in NSW.
The Australian Energy Regulator forecast energy contract prices to double by 2029.
Electricity accounts for more than 40 per cent of its operating costs and Tomago Aluminium warned it would not remain commercially viable if prices rise.
After months of negotiations, the NSW government and the Commonwealth have agreed to commit $2.5 billion to assist in entering into long-term energy contracts to in 2029.
Tomago Aluminium have agreed to invest a further $1.1 billion to decarbonise and upgrade its facilities to better adapt to fluctuations in renewable energy supply and demand.
The focus will now move to the long-term viability of the site.
Industry Minister Tim Ayres refused to comment on what the revenue return for taxpayers would be from the investment, instead labelling it a "complex and large arrangement".
"(This is) a tough thing for the governments to work through and to deliver together, but it's manifestly in the national interest," he told ABC Radio National on Wednesday, defending the bailout of one of Australia's largest mining companies.
Even so, Prime Minister Anthony Albanese said keeping the smelter operating was critical for Australia's manufacturing future.
"In December last year, I stood in the rain at Tomago and told the workers 'we have your back'," Mr Albanese said in a statement."Today, alongside the NSW government, we deliver on that promise."
Australian Manufacturing Workers' Union NSW and ACT state secretary Brad Pidgeon said after months of uncertainty, workers can finally feel confidence about the future.
"This is a win for working class people in the Hunter that is a testament to the tireless advocacy of our members on the job," he said.
For Brad McDougall, he said the smelter has been at the heart of the Hunter economy for decades.
"The local community has been campaigning tirelessly for the smelter to be protected, and today that hard work has finally paid off," the Electrical Trades Union NSW/ACT organiser added.
"Thousands of local families rely on Tomago. This is a massive win."
Premier Chris Minns welcomed the agreement, in which NSW would contribute almost half the funding.
Mr Minns said the Hunter had been an industrial and manufacturing powerhouse with the agreement to make sure it remained so "for generations to come."
Tomago Aluminium produces up to 590,000 tonnes of aluminium a year.
Smelter chief executive Jerome Dozol warned in 2025 the facility would have to close without government intervention on future energy prices from renewable and fossil fuel sources.
Tomago smelter majority owner Rio Tinto reported increasing profits of $6.9 billion in the first half of 2026.
It's the latest in a string of bailouts from state and federal governments for metal processing infrastructure.
The federal government has promised billions in propping up facilities including the Whyalla steelworks, Mount Isa copper smelter and the Boyne aluminium smelter in recent years.